// $ANTLR 3.2 Sep 23, 2009 12:02:23 WJ.g 2013-12-11 02:51:43

	package wj;
	import java.util.HashMap;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;


import org.antlr.runtime.tree.*;

public class WJParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "BLOCK", "STATEMENTS", "RETURN", "DECLARATION", "ASSIGNMENT", "ARG_LIST", "PARAM_LIST", "FUNCTION_CALL", "IF", "ELSE_IF", "ELSE", "NEGATE", "NOT", "OR", "AND", "POW", "ADDSUB", "MULDIVMOD", "RELATIONAL", "Return", "Identifier", "CreateFunction", "WithParameters", "EndFunction", "Write", "WriteLine", "ReadString", "ReadNumber", "Connect", "Length", "CharAt", "Take", "Drop", "String", "EndIf", "If", "ElseIf", "Else", "Number", "Boolean", "Declare", "ThatReturns", "Int", "Digit", "AlphaChar", "Space", "Comment", "'.'", "'gets'", "'('", "')'", "':'", "','", "'()'", "'['", "']'", "'characters'", "'from'", "'then'", "'while'", "'is'", "'correct'", "'end while'", "'or'", "'and'", "'=='", "'!='", "'>='", "'<='", "'>'", "'<'", "'+'", "'-'", "'*'", "'/'", "'mod'", "'^'", "'!'"
    };
    public static final int T__68=68;
    public static final int T__69=69;
    public static final int T__66=66;
    public static final int T__67=67;
    public static final int T__64=64;
    public static final int T__65=65;
    public static final int T__62=62;
    public static final int T__63=63;
    public static final int Connect=32;
    public static final int CreateFunction=25;
    public static final int NOT=16;
    public static final int AND=18;
    public static final int T__61=61;
    public static final int T__60=60;
    public static final int EOF=-1;
    public static final int DECLARATION=7;
    public static final int Int=46;
    public static final int Identifier=24;
    public static final int IF=12;
    public static final int Space=49;
    public static final int T__55=55;
    public static final int T__56=56;
    public static final int T__57=57;
    public static final int T__58=58;
    public static final int EndIf=38;
    public static final int T__51=51;
    public static final int POW=19;
    public static final int T__52=52;
    public static final int Number=42;
    public static final int T__53=53;
    public static final int Take=35;
    public static final int T__54=54;
    public static final int Comment=50;
    public static final int T__59=59;
    public static final int RETURN=6;
    public static final int WithParameters=26;
    public static final int String=37;
    public static final int ReadNumber=31;
    public static final int Return=23;
    public static final int AlphaChar=48;
    public static final int If=39;
    public static final int ELSE_IF=13;
    public static final int T__80=80;
    public static final int T__81=81;
    public static final int EndFunction=27;
    public static final int ELSE=14;
    public static final int Declare=44;
    public static final int ElseIf=40;
    public static final int NEGATE=15;
    public static final int ARG_LIST=9;
    public static final int Drop=36;
    public static final int Write=28;
    public static final int Digit=47;
    public static final int RELATIONAL=22;
    public static final int PARAM_LIST=10;
    public static final int T__71=71;
    public static final int ADDSUB=20;
    public static final int T__72=72;
    public static final int MULDIVMOD=21;
    public static final int T__70=70;
    public static final int Boolean=43;
    public static final int BLOCK=4;
    public static final int OR=17;
    public static final int WriteLine=29;
    public static final int STATEMENTS=5;
    public static final int ASSIGNMENT=8;
    public static final int CharAt=34;
    public static final int Length=33;
    public static final int ReadString=30;
    public static final int T__76=76;
    public static final int Else=41;
    public static final int T__75=75;
    public static final int FUNCTION_CALL=11;
    public static final int T__74=74;
    public static final int ThatReturns=45;
    public static final int T__73=73;
    public static final int T__79=79;
    public static final int T__78=78;
    public static final int T__77=77;

    // delegates
    // delegators


        public WJParser(TokenStream input) {
            this(input, new RecognizerSharedState());
        }
        public WJParser(TokenStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        
    protected TreeAdaptor adaptor = new CommonTreeAdaptor();

    public void setTreeAdaptor(TreeAdaptor adaptor) {
        this.adaptor = adaptor;
    }
    public TreeAdaptor getTreeAdaptor() {
        return adaptor;
    }

    public String[] getTokenNames() { return WJParser.tokenNames; }
    public String getGrammarFileName() { return "WJ.g"; }



      public static HashMap<String, Function> functions = new HashMap<String, Function>();
      
        private void defineFunction(String id, ArrayList<String> parameterList,  Object block) {

        // `block` is never null.
        CommonTree blockTree = (CommonTree)block;

        // The function name with the number of parameters after it the unique key
    	if(parameterList == null)
    		parameterList = new ArrayList<String>();
    	
        String key = id +"-"+parameterList.size();
        functions.put(key, new Function(id, parameterList, blockTree));
      }
      


    public static class parse_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "parse"
    // WJ.g:57:1: parse : block EOF -> block ;
    public final WJParser.parse_return parse() throws RecognitionException {
        WJParser.parse_return retval = new WJParser.parse_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token EOF2=null;
        WJParser.block_return block1 = null;


        Object EOF2_tree=null;
        RewriteRuleTokenStream stream_EOF=new RewriteRuleTokenStream(adaptor,"token EOF");
        RewriteRuleSubtreeStream stream_block=new RewriteRuleSubtreeStream(adaptor,"rule block");
        try {
            // WJ.g:58:3: ( block EOF -> block )
            // WJ.g:58:6: block EOF
            {
            pushFollow(FOLLOW_block_in_parse139);
            block1=block();

            state._fsp--;

            stream_block.add(block1.getTree());
            EOF2=(Token)match(input,EOF,FOLLOW_EOF_in_parse141);  
            stream_EOF.add(EOF2);



            // AST REWRITE
            // elements: block
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 58:16: -> block
            {
                adaptor.addChild(root_0, stream_block.nextTree());

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "parse"

    public static class block_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "block"
    // WJ.g:61:1: block : ( statement | functionDeclaration )* ( Return expression '.' )? -> ^( BLOCK ^( STATEMENTS ( statement )* ) ^( RETURN ( expression )? ) ) ;
    public final WJParser.block_return block() throws RecognitionException {
        WJParser.block_return retval = new WJParser.block_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token Return5=null;
        Token char_literal7=null;
        WJParser.statement_return statement3 = null;

        WJParser.functionDeclaration_return functionDeclaration4 = null;

        WJParser.expression_return expression6 = null;


        Object Return5_tree=null;
        Object char_literal7_tree=null;
        RewriteRuleTokenStream stream_51=new RewriteRuleTokenStream(adaptor,"token 51");
        RewriteRuleTokenStream stream_Return=new RewriteRuleTokenStream(adaptor,"token Return");
        RewriteRuleSubtreeStream stream_statement=new RewriteRuleSubtreeStream(adaptor,"rule statement");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        RewriteRuleSubtreeStream stream_functionDeclaration=new RewriteRuleSubtreeStream(adaptor,"rule functionDeclaration");
        try {
            // WJ.g:62:3: ( ( statement | functionDeclaration )* ( Return expression '.' )? -> ^( BLOCK ^( STATEMENTS ( statement )* ) ^( RETURN ( expression )? ) ) )
            // WJ.g:62:6: ( statement | functionDeclaration )* ( Return expression '.' )?
            {
            // WJ.g:62:6: ( statement | functionDeclaration )*
            loop1:
            do {
                int alt1=3;
                int LA1_0 = input.LA(1);

                if ( (LA1_0==Identifier||(LA1_0>=Write && LA1_0<=Connect)||(LA1_0>=Take && LA1_0<=String)||LA1_0==If||LA1_0==63) ) {
                    alt1=1;
                }
                else if ( (LA1_0==CreateFunction) ) {
                    alt1=2;
                }


                switch (alt1) {
            	case 1 :
            	    // WJ.g:62:7: statement
            	    {
            	    pushFollow(FOLLOW_statement_in_block166);
            	    statement3=statement();

            	    state._fsp--;

            	    stream_statement.add(statement3.getTree());

            	    }
            	    break;
            	case 2 :
            	    // WJ.g:62:19: functionDeclaration
            	    {
            	    pushFollow(FOLLOW_functionDeclaration_in_block170);
            	    functionDeclaration4=functionDeclaration();

            	    state._fsp--;

            	    stream_functionDeclaration.add(functionDeclaration4.getTree());

            	    }
            	    break;

            	default :
            	    break loop1;
                }
            } while (true);

            // WJ.g:62:41: ( Return expression '.' )?
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( (LA2_0==Return) ) {
                alt2=1;
            }
            switch (alt2) {
                case 1 :
                    // WJ.g:62:42: Return expression '.'
                    {
                    Return5=(Token)match(input,Return,FOLLOW_Return_in_block175);  
                    stream_Return.add(Return5);

                    pushFollow(FOLLOW_expression_in_block177);
                    expression6=expression();

                    state._fsp--;

                    stream_expression.add(expression6.getTree());
                    char_literal7=(Token)match(input,51,FOLLOW_51_in_block179);  
                    stream_51.add(char_literal7);


                    }
                    break;

            }



            // AST REWRITE
            // elements: statement, expression
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 63:3: -> ^( BLOCK ^( STATEMENTS ( statement )* ) ^( RETURN ( expression )? ) )
            {
                // WJ.g:63:6: ^( BLOCK ^( STATEMENTS ( statement )* ) ^( RETURN ( expression )? ) )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(BLOCK, "BLOCK"), root_1);

                // WJ.g:63:14: ^( STATEMENTS ( statement )* )
                {
                Object root_2 = (Object)adaptor.nil();
                root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(STATEMENTS, "STATEMENTS"), root_2);

                // WJ.g:63:27: ( statement )*
                while ( stream_statement.hasNext() ) {
                    adaptor.addChild(root_2, stream_statement.nextTree());

                }
                stream_statement.reset();

                adaptor.addChild(root_1, root_2);
                }
                // WJ.g:63:39: ^( RETURN ( expression )? )
                {
                Object root_2 = (Object)adaptor.nil();
                root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(RETURN, "RETURN"), root_2);

                // WJ.g:63:48: ( expression )?
                if ( stream_expression.hasNext() ) {
                    adaptor.addChild(root_2, stream_expression.nextTree());

                }
                stream_expression.reset();

                adaptor.addChild(root_1, root_2);
                }

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "block"

    public static class statement_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "statement"
    // WJ.g:66:1: statement : ( assignment '.' -> assignment | functionCall '.' -> functionCall | ifStatement -> ifStatement | whileStatement -> whileStatement );
    public final WJParser.statement_return statement() throws RecognitionException {
        WJParser.statement_return retval = new WJParser.statement_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token char_literal9=null;
        Token char_literal11=null;
        WJParser.assignment_return assignment8 = null;

        WJParser.functionCall_return functionCall10 = null;

        WJParser.ifStatement_return ifStatement12 = null;

        WJParser.whileStatement_return whileStatement13 = null;


        Object char_literal9_tree=null;
        Object char_literal11_tree=null;
        RewriteRuleTokenStream stream_51=new RewriteRuleTokenStream(adaptor,"token 51");
        RewriteRuleSubtreeStream stream_functionCall=new RewriteRuleSubtreeStream(adaptor,"rule functionCall");
        RewriteRuleSubtreeStream stream_assignment=new RewriteRuleSubtreeStream(adaptor,"rule assignment");
        RewriteRuleSubtreeStream stream_whileStatement=new RewriteRuleSubtreeStream(adaptor,"rule whileStatement");
        RewriteRuleSubtreeStream stream_ifStatement=new RewriteRuleSubtreeStream(adaptor,"rule ifStatement");
        try {
            // WJ.g:67:2: ( assignment '.' -> assignment | functionCall '.' -> functionCall | ifStatement -> ifStatement | whileStatement -> whileStatement )
            int alt3=4;
            switch ( input.LA(1) ) {
            case Identifier:
                {
                int LA3_1 = input.LA(2);

                if ( (LA3_1==52) ) {
                    alt3=1;
                }
                else if ( ((LA3_1>=Length && LA3_1<=CharAt)||LA3_1==53||LA3_1==57) ) {
                    alt3=2;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("", 3, 1, input);

                    throw nvae;
                }
                }
                break;
            case Write:
            case WriteLine:
            case ReadString:
            case ReadNumber:
            case Connect:
            case Take:
            case Drop:
            case String:
                {
                alt3=2;
                }
                break;
            case If:
                {
                alt3=3;
                }
                break;
            case 63:
                {
                alt3=4;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 3, 0, input);

                throw nvae;
            }

            switch (alt3) {
                case 1 :
                    // WJ.g:67:4: assignment '.'
                    {
                    pushFollow(FOLLOW_assignment_in_statement221);
                    assignment8=assignment();

                    state._fsp--;

                    stream_assignment.add(assignment8.getTree());
                    char_literal9=(Token)match(input,51,FOLLOW_51_in_statement224);  
                    stream_51.add(char_literal9);



                    // AST REWRITE
                    // elements: assignment
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 67:21: -> assignment
                    {
                        adaptor.addChild(root_0, stream_assignment.nextTree());

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 2 :
                    // WJ.g:68:4: functionCall '.'
                    {
                    pushFollow(FOLLOW_functionCall_in_statement234);
                    functionCall10=functionCall();

                    state._fsp--;

                    stream_functionCall.add(functionCall10.getTree());
                    char_literal11=(Token)match(input,51,FOLLOW_51_in_statement236);  
                    stream_51.add(char_literal11);



                    // AST REWRITE
                    // elements: functionCall
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 68:21: -> functionCall
                    {
                        adaptor.addChild(root_0, stream_functionCall.nextTree());

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 3 :
                    // WJ.g:69:4: ifStatement
                    {
                    pushFollow(FOLLOW_ifStatement_in_statement245);
                    ifStatement12=ifStatement();

                    state._fsp--;

                    stream_ifStatement.add(ifStatement12.getTree());


                    // AST REWRITE
                    // elements: ifStatement
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 69:18: -> ifStatement
                    {
                        adaptor.addChild(root_0, stream_ifStatement.nextTree());

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 4 :
                    // WJ.g:70:4: whileStatement
                    {
                    pushFollow(FOLLOW_whileStatement_in_statement256);
                    whileStatement13=whileStatement();

                    state._fsp--;

                    stream_whileStatement.add(whileStatement13.getTree());


                    // AST REWRITE
                    // elements: whileStatement
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 70:20: -> whileStatement
                    {
                        adaptor.addChild(root_0, stream_whileStatement.nextTree());

                    }

                    retval.tree = root_0;
                    }
                    break;

            }
            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "statement"

    public static class assignment_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "assignment"
    // WJ.g:73:1: assignment : Identifier 'gets' expression -> ^( ASSIGNMENT Identifier expression ) ;
    public final WJParser.assignment_return assignment() throws RecognitionException {
        WJParser.assignment_return retval = new WJParser.assignment_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token Identifier14=null;
        Token string_literal15=null;
        WJParser.expression_return expression16 = null;


        Object Identifier14_tree=null;
        Object string_literal15_tree=null;
        RewriteRuleTokenStream stream_52=new RewriteRuleTokenStream(adaptor,"token 52");
        RewriteRuleTokenStream stream_Identifier=new RewriteRuleTokenStream(adaptor,"token Identifier");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        try {
            // WJ.g:74:2: ( Identifier 'gets' expression -> ^( ASSIGNMENT Identifier expression ) )
            // WJ.g:74:5: Identifier 'gets' expression
            {
            Identifier14=(Token)match(input,Identifier,FOLLOW_Identifier_in_assignment275);  
            stream_Identifier.add(Identifier14);

            string_literal15=(Token)match(input,52,FOLLOW_52_in_assignment277);  
            stream_52.add(string_literal15);

            pushFollow(FOLLOW_expression_in_assignment279);
            expression16=expression();

            state._fsp--;

            stream_expression.add(expression16.getTree());


            // AST REWRITE
            // elements: expression, Identifier
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 74:34: -> ^( ASSIGNMENT Identifier expression )
            {
                // WJ.g:74:37: ^( ASSIGNMENT Identifier expression )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(ASSIGNMENT, "ASSIGNMENT"), root_1);

                adaptor.addChild(root_1, stream_Identifier.nextNode());
                adaptor.addChild(root_1, stream_expression.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "assignment"

    public static class functionDeclaration_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "functionDeclaration"
    // WJ.g:77:1: functionDeclaration : CreateFunction Identifier ( WithParameters '(' ( parameterList )* ')' )? ':' block EndFunction ;
    public final WJParser.functionDeclaration_return functionDeclaration() throws RecognitionException {
        WJParser.functionDeclaration_return retval = new WJParser.functionDeclaration_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token CreateFunction17=null;
        Token Identifier18=null;
        Token WithParameters19=null;
        Token char_literal20=null;
        Token char_literal22=null;
        Token char_literal23=null;
        Token EndFunction25=null;
        WJParser.parameterList_return parameterList21 = null;

        WJParser.block_return block24 = null;


        Object CreateFunction17_tree=null;
        Object Identifier18_tree=null;
        Object WithParameters19_tree=null;
        Object char_literal20_tree=null;
        Object char_literal22_tree=null;
        Object char_literal23_tree=null;
        Object EndFunction25_tree=null;

        try {
            // WJ.g:78:2: ( CreateFunction Identifier ( WithParameters '(' ( parameterList )* ')' )? ':' block EndFunction )
            // WJ.g:78:5: CreateFunction Identifier ( WithParameters '(' ( parameterList )* ')' )? ':' block EndFunction
            {
            root_0 = (Object)adaptor.nil();

            CreateFunction17=(Token)match(input,CreateFunction,FOLLOW_CreateFunction_in_functionDeclaration303); 
            CreateFunction17_tree = (Object)adaptor.create(CreateFunction17);
            adaptor.addChild(root_0, CreateFunction17_tree);

            Identifier18=(Token)match(input,Identifier,FOLLOW_Identifier_in_functionDeclaration305); 
            Identifier18_tree = (Object)adaptor.create(Identifier18);
            adaptor.addChild(root_0, Identifier18_tree);

            // WJ.g:78:31: ( WithParameters '(' ( parameterList )* ')' )?
            int alt5=2;
            int LA5_0 = input.LA(1);

            if ( (LA5_0==WithParameters) ) {
                alt5=1;
            }
            switch (alt5) {
                case 1 :
                    // WJ.g:78:32: WithParameters '(' ( parameterList )* ')'
                    {
                    WithParameters19=(Token)match(input,WithParameters,FOLLOW_WithParameters_in_functionDeclaration308); 
                    WithParameters19_tree = (Object)adaptor.create(WithParameters19);
                    adaptor.addChild(root_0, WithParameters19_tree);

                    char_literal20=(Token)match(input,53,FOLLOW_53_in_functionDeclaration310); 
                    char_literal20_tree = (Object)adaptor.create(char_literal20);
                    adaptor.addChild(root_0, char_literal20_tree);

                    // WJ.g:78:51: ( parameterList )*
                    loop4:
                    do {
                        int alt4=2;
                        int LA4_0 = input.LA(1);

                        if ( (LA4_0==Identifier) ) {
                            alt4=1;
                        }


                        switch (alt4) {
                    	case 1 :
                    	    // WJ.g:78:51: parameterList
                    	    {
                    	    pushFollow(FOLLOW_parameterList_in_functionDeclaration312);
                    	    parameterList21=parameterList();

                    	    state._fsp--;

                    	    adaptor.addChild(root_0, parameterList21.getTree());

                    	    }
                    	    break;

                    	default :
                    	    break loop4;
                        }
                    } while (true);

                    char_literal22=(Token)match(input,54,FOLLOW_54_in_functionDeclaration315); 
                    char_literal22_tree = (Object)adaptor.create(char_literal22);
                    adaptor.addChild(root_0, char_literal22_tree);


                    }
                    break;

            }

            char_literal23=(Token)match(input,55,FOLLOW_55_in_functionDeclaration319); 
            char_literal23_tree = (Object)adaptor.create(char_literal23);
            adaptor.addChild(root_0, char_literal23_tree);

            pushFollow(FOLLOW_block_in_functionDeclaration321);
            block24=block();

            state._fsp--;

            adaptor.addChild(root_0, block24.getTree());
            EndFunction25=(Token)match(input,EndFunction,FOLLOW_EndFunction_in_functionDeclaration323); 
            EndFunction25_tree = (Object)adaptor.create(EndFunction25);
            adaptor.addChild(root_0, EndFunction25_tree);

             defineFunction((Identifier18!=null?Identifier18.getText():null), (parameterList21!=null?parameterList21.parameterList:null), (block24!=null?((Object)block24.tree):null));

            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "functionDeclaration"

    public static class argumentList_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "argumentList"
    // WJ.g:81:1: argumentList : expression ( ',' expression )* -> ^( ARG_LIST ( expression )+ ) ;
    public final WJParser.argumentList_return argumentList() throws RecognitionException {
        WJParser.argumentList_return retval = new WJParser.argumentList_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token char_literal27=null;
        WJParser.expression_return expression26 = null;

        WJParser.expression_return expression28 = null;


        Object char_literal27_tree=null;
        RewriteRuleTokenStream stream_56=new RewriteRuleTokenStream(adaptor,"token 56");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        try {
            // WJ.g:81:13: ( expression ( ',' expression )* -> ^( ARG_LIST ( expression )+ ) )
            // WJ.g:81:15: expression ( ',' expression )*
            {
            pushFollow(FOLLOW_expression_in_argumentList335);
            expression26=expression();

            state._fsp--;

            stream_expression.add(expression26.getTree());
            // WJ.g:81:26: ( ',' expression )*
            loop6:
            do {
                int alt6=2;
                int LA6_0 = input.LA(1);

                if ( (LA6_0==56) ) {
                    alt6=1;
                }


                switch (alt6) {
            	case 1 :
            	    // WJ.g:81:27: ',' expression
            	    {
            	    char_literal27=(Token)match(input,56,FOLLOW_56_in_argumentList338);  
            	    stream_56.add(char_literal27);

            	    pushFollow(FOLLOW_expression_in_argumentList340);
            	    expression28=expression();

            	    state._fsp--;

            	    stream_expression.add(expression28.getTree());

            	    }
            	    break;

            	default :
            	    break loop6;
                }
            } while (true);



            // AST REWRITE
            // elements: expression
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 81:44: -> ^( ARG_LIST ( expression )+ )
            {
                // WJ.g:81:47: ^( ARG_LIST ( expression )+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(ARG_LIST, "ARG_LIST"), root_1);

                if ( !(stream_expression.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_expression.hasNext() ) {
                    adaptor.addChild(root_1, stream_expression.nextTree());

                }
                stream_expression.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "argumentList"

    public static class parameterList_return extends ParserRuleReturnScope {
        public ArrayList<String> parameterList;
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "parameterList"
    // WJ.g:83:1: parameterList returns [ArrayList<String> parameterList] : a= Identifier ( ',' b= Identifier )* -> ^( PARAM_LIST ( Identifier )+ ) ;
    public final WJParser.parameterList_return parameterList() throws RecognitionException {
        WJParser.parameterList_return retval = new WJParser.parameterList_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token a=null;
        Token b=null;
        Token char_literal29=null;

        Object a_tree=null;
        Object b_tree=null;
        Object char_literal29_tree=null;
        RewriteRuleTokenStream stream_56=new RewriteRuleTokenStream(adaptor,"token 56");
        RewriteRuleTokenStream stream_Identifier=new RewriteRuleTokenStream(adaptor,"token Identifier");


        	retval.parameterList = new ArrayList<String>();

        try {
            // WJ.g:87:3: (a= Identifier ( ',' b= Identifier )* -> ^( PARAM_LIST ( Identifier )+ ) )
            // WJ.g:87:7: a= Identifier ( ',' b= Identifier )*
            {
            a=(Token)match(input,Identifier,FOLLOW_Identifier_in_parameterList373);  
            stream_Identifier.add(a);

            retval.parameterList.add((a!=null?a.getText():null));
            // WJ.g:87:50: ( ',' b= Identifier )*
            loop7:
            do {
                int alt7=2;
                int LA7_0 = input.LA(1);

                if ( (LA7_0==56) ) {
                    alt7=1;
                }


                switch (alt7) {
            	case 1 :
            	    // WJ.g:87:51: ',' b= Identifier
            	    {
            	    char_literal29=(Token)match(input,56,FOLLOW_56_in_parameterList377);  
            	    stream_56.add(char_literal29);

            	    b=(Token)match(input,Identifier,FOLLOW_Identifier_in_parameterList381);  
            	    stream_Identifier.add(b);

            	    retval.parameterList.add((b!=null?b.getText():null));

            	    }
            	    break;

            	default :
            	    break loop7;
                }
            } while (true);



            // AST REWRITE
            // elements: Identifier
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 87:100: -> ^( PARAM_LIST ( Identifier )+ )
            {
                // WJ.g:87:103: ^( PARAM_LIST ( Identifier )+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(PARAM_LIST, "PARAM_LIST"), root_1);

                if ( !(stream_Identifier.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_Identifier.hasNext() ) {
                    adaptor.addChild(root_1, stream_Identifier.nextNode());

                }
                stream_Identifier.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "parameterList"

    public static class functionCall_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "functionCall"
    // WJ.g:90:1: functionCall : ( Write ( '()' | '(' ( expression )? ')' ) -> ^( FUNCTION_CALL Write ( expression )? ) | WriteLine ( '()' | '(' ( expression )? ')' ) -> ^( FUNCTION_CALL WriteLine ( expression )? ) | ReadString ( '()' | '(' ')' ) -> ^( FUNCTION_CALL ReadString ) | ReadNumber ( '()' | '(' ')' ) -> ^( FUNCTION_CALL ReadNumber ) | Connect '(' expression ( ',' expression )+ ')' -> ^( FUNCTION_CALL Connect ( expression )+ ) | stringExpr Length -> ^( FUNCTION_CALL Length stringExpr ) | stringExpr CharAt '[' expression ']' -> ^( FUNCTION_CALL CharAt stringExpr expression ) | Take expression 'characters' 'from' stringExpr -> ^( FUNCTION_CALL Take expression stringExpr ) | Drop expression 'characters' 'from' stringExpr -> ^( FUNCTION_CALL Drop expression stringExpr ) | Identifier ( '()' | '(' ( argumentList )? ')' ) -> ^( FUNCTION_CALL Identifier ( argumentList )? ) );
    public final WJParser.functionCall_return functionCall() throws RecognitionException {
        WJParser.functionCall_return retval = new WJParser.functionCall_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token Write30=null;
        Token string_literal31=null;
        Token char_literal32=null;
        Token char_literal34=null;
        Token WriteLine35=null;
        Token string_literal36=null;
        Token char_literal37=null;
        Token char_literal39=null;
        Token ReadString40=null;
        Token string_literal41=null;
        Token char_literal42=null;
        Token char_literal43=null;
        Token ReadNumber44=null;
        Token string_literal45=null;
        Token char_literal46=null;
        Token char_literal47=null;
        Token Connect48=null;
        Token char_literal49=null;
        Token char_literal51=null;
        Token char_literal53=null;
        Token Length55=null;
        Token CharAt57=null;
        Token char_literal58=null;
        Token char_literal60=null;
        Token Take61=null;
        Token string_literal63=null;
        Token string_literal64=null;
        Token Drop66=null;
        Token string_literal68=null;
        Token string_literal69=null;
        Token Identifier71=null;
        Token string_literal72=null;
        Token char_literal73=null;
        Token char_literal75=null;
        WJParser.expression_return expression33 = null;

        WJParser.expression_return expression38 = null;

        WJParser.expression_return expression50 = null;

        WJParser.expression_return expression52 = null;

        WJParser.stringExpr_return stringExpr54 = null;

        WJParser.stringExpr_return stringExpr56 = null;

        WJParser.expression_return expression59 = null;

        WJParser.expression_return expression62 = null;

        WJParser.stringExpr_return stringExpr65 = null;

        WJParser.expression_return expression67 = null;

        WJParser.stringExpr_return stringExpr70 = null;

        WJParser.argumentList_return argumentList74 = null;


        Object Write30_tree=null;
        Object string_literal31_tree=null;
        Object char_literal32_tree=null;
        Object char_literal34_tree=null;
        Object WriteLine35_tree=null;
        Object string_literal36_tree=null;
        Object char_literal37_tree=null;
        Object char_literal39_tree=null;
        Object ReadString40_tree=null;
        Object string_literal41_tree=null;
        Object char_literal42_tree=null;
        Object char_literal43_tree=null;
        Object ReadNumber44_tree=null;
        Object string_literal45_tree=null;
        Object char_literal46_tree=null;
        Object char_literal47_tree=null;
        Object Connect48_tree=null;
        Object char_literal49_tree=null;
        Object char_literal51_tree=null;
        Object char_literal53_tree=null;
        Object Length55_tree=null;
        Object CharAt57_tree=null;
        Object char_literal58_tree=null;
        Object char_literal60_tree=null;
        Object Take61_tree=null;
        Object string_literal63_tree=null;
        Object string_literal64_tree=null;
        Object Drop66_tree=null;
        Object string_literal68_tree=null;
        Object string_literal69_tree=null;
        Object Identifier71_tree=null;
        Object string_literal72_tree=null;
        Object char_literal73_tree=null;
        Object char_literal75_tree=null;
        RewriteRuleTokenStream stream_59=new RewriteRuleTokenStream(adaptor,"token 59");
        RewriteRuleTokenStream stream_58=new RewriteRuleTokenStream(adaptor,"token 58");
        RewriteRuleTokenStream stream_57=new RewriteRuleTokenStream(adaptor,"token 57");
        RewriteRuleTokenStream stream_56=new RewriteRuleTokenStream(adaptor,"token 56");
        RewriteRuleTokenStream stream_Take=new RewriteRuleTokenStream(adaptor,"token Take");
        RewriteRuleTokenStream stream_Connect=new RewriteRuleTokenStream(adaptor,"token Connect");
        RewriteRuleTokenStream stream_WriteLine=new RewriteRuleTokenStream(adaptor,"token WriteLine");
        RewriteRuleTokenStream stream_Drop=new RewriteRuleTokenStream(adaptor,"token Drop");
        RewriteRuleTokenStream stream_Write=new RewriteRuleTokenStream(adaptor,"token Write");
        RewriteRuleTokenStream stream_ReadNumber=new RewriteRuleTokenStream(adaptor,"token ReadNumber");
        RewriteRuleTokenStream stream_CharAt=new RewriteRuleTokenStream(adaptor,"token CharAt");
        RewriteRuleTokenStream stream_ReadString=new RewriteRuleTokenStream(adaptor,"token ReadString");
        RewriteRuleTokenStream stream_Length=new RewriteRuleTokenStream(adaptor,"token Length");
        RewriteRuleTokenStream stream_53=new RewriteRuleTokenStream(adaptor,"token 53");
        RewriteRuleTokenStream stream_54=new RewriteRuleTokenStream(adaptor,"token 54");
        RewriteRuleTokenStream stream_Identifier=new RewriteRuleTokenStream(adaptor,"token Identifier");
        RewriteRuleTokenStream stream_60=new RewriteRuleTokenStream(adaptor,"token 60");
        RewriteRuleTokenStream stream_61=new RewriteRuleTokenStream(adaptor,"token 61");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        RewriteRuleSubtreeStream stream_stringExpr=new RewriteRuleSubtreeStream(adaptor,"rule stringExpr");
        RewriteRuleSubtreeStream stream_argumentList=new RewriteRuleSubtreeStream(adaptor,"rule argumentList");
        try {
            // WJ.g:91:2: ( Write ( '()' | '(' ( expression )? ')' ) -> ^( FUNCTION_CALL Write ( expression )? ) | WriteLine ( '()' | '(' ( expression )? ')' ) -> ^( FUNCTION_CALL WriteLine ( expression )? ) | ReadString ( '()' | '(' ')' ) -> ^( FUNCTION_CALL ReadString ) | ReadNumber ( '()' | '(' ')' ) -> ^( FUNCTION_CALL ReadNumber ) | Connect '(' expression ( ',' expression )+ ')' -> ^( FUNCTION_CALL Connect ( expression )+ ) | stringExpr Length -> ^( FUNCTION_CALL Length stringExpr ) | stringExpr CharAt '[' expression ']' -> ^( FUNCTION_CALL CharAt stringExpr expression ) | Take expression 'characters' 'from' stringExpr -> ^( FUNCTION_CALL Take expression stringExpr ) | Drop expression 'characters' 'from' stringExpr -> ^( FUNCTION_CALL Drop expression stringExpr ) | Identifier ( '()' | '(' ( argumentList )? ')' ) -> ^( FUNCTION_CALL Identifier ( argumentList )? ) )
            int alt17=10;
            alt17 = dfa17.predict(input);
            switch (alt17) {
                case 1 :
                    // WJ.g:91:4: Write ( '()' | '(' ( expression )? ')' )
                    {
                    Write30=(Token)match(input,Write,FOLLOW_Write_in_functionCall408);  
                    stream_Write.add(Write30);

                    // WJ.g:91:11: ( '()' | '(' ( expression )? ')' )
                    int alt9=2;
                    int LA9_0 = input.LA(1);

                    if ( (LA9_0==57) ) {
                        alt9=1;
                    }
                    else if ( (LA9_0==53) ) {
                        alt9=2;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("", 9, 0, input);

                        throw nvae;
                    }
                    switch (alt9) {
                        case 1 :
                            // WJ.g:91:12: '()'
                            {
                            string_literal31=(Token)match(input,57,FOLLOW_57_in_functionCall412);  
                            stream_57.add(string_literal31);


                            }
                            break;
                        case 2 :
                            // WJ.g:91:19: '(' ( expression )? ')'
                            {
                            char_literal32=(Token)match(input,53,FOLLOW_53_in_functionCall416);  
                            stream_53.add(char_literal32);

                            // WJ.g:91:23: ( expression )?
                            int alt8=2;
                            int LA8_0 = input.LA(1);

                            if ( (LA8_0==Identifier||(LA8_0>=Write && LA8_0<=Connect)||(LA8_0>=Take && LA8_0<=String)||(LA8_0>=Number && LA8_0<=Boolean)||LA8_0==53||LA8_0==76||LA8_0==81) ) {
                                alt8=1;
                            }
                            switch (alt8) {
                                case 1 :
                                    // WJ.g:91:23: expression
                                    {
                                    pushFollow(FOLLOW_expression_in_functionCall418);
                                    expression33=expression();

                                    state._fsp--;

                                    stream_expression.add(expression33.getTree());

                                    }
                                    break;

                            }

                            char_literal34=(Token)match(input,54,FOLLOW_54_in_functionCall421);  
                            stream_54.add(char_literal34);


                            }
                            break;

                    }



                    // AST REWRITE
                    // elements: Write, expression
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 91:40: -> ^( FUNCTION_CALL Write ( expression )? )
                    {
                        // WJ.g:91:43: ^( FUNCTION_CALL Write ( expression )? )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(FUNCTION_CALL, "FUNCTION_CALL"), root_1);

                        adaptor.addChild(root_1, stream_Write.nextNode());
                        // WJ.g:91:65: ( expression )?
                        if ( stream_expression.hasNext() ) {
                            adaptor.addChild(root_1, stream_expression.nextTree());

                        }
                        stream_expression.reset();

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 2 :
                    // WJ.g:92:4: WriteLine ( '()' | '(' ( expression )? ')' )
                    {
                    WriteLine35=(Token)match(input,WriteLine,FOLLOW_WriteLine_in_functionCall438);  
                    stream_WriteLine.add(WriteLine35);

                    // WJ.g:92:14: ( '()' | '(' ( expression )? ')' )
                    int alt11=2;
                    int LA11_0 = input.LA(1);

                    if ( (LA11_0==57) ) {
                        alt11=1;
                    }
                    else if ( (LA11_0==53) ) {
                        alt11=2;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("", 11, 0, input);

                        throw nvae;
                    }
                    switch (alt11) {
                        case 1 :
                            // WJ.g:92:15: '()'
                            {
                            string_literal36=(Token)match(input,57,FOLLOW_57_in_functionCall441);  
                            stream_57.add(string_literal36);


                            }
                            break;
                        case 2 :
                            // WJ.g:92:22: '(' ( expression )? ')'
                            {
                            char_literal37=(Token)match(input,53,FOLLOW_53_in_functionCall445);  
                            stream_53.add(char_literal37);

                            // WJ.g:92:26: ( expression )?
                            int alt10=2;
                            int LA10_0 = input.LA(1);

                            if ( (LA10_0==Identifier||(LA10_0>=Write && LA10_0<=Connect)||(LA10_0>=Take && LA10_0<=String)||(LA10_0>=Number && LA10_0<=Boolean)||LA10_0==53||LA10_0==76||LA10_0==81) ) {
                                alt10=1;
                            }
                            switch (alt10) {
                                case 1 :
                                    // WJ.g:92:26: expression
                                    {
                                    pushFollow(FOLLOW_expression_in_functionCall447);
                                    expression38=expression();

                                    state._fsp--;

                                    stream_expression.add(expression38.getTree());

                                    }
                                    break;

                            }

                            char_literal39=(Token)match(input,54,FOLLOW_54_in_functionCall450);  
                            stream_54.add(char_literal39);


                            }
                            break;

                    }



                    // AST REWRITE
                    // elements: WriteLine, expression
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 92:43: -> ^( FUNCTION_CALL WriteLine ( expression )? )
                    {
                        // WJ.g:92:46: ^( FUNCTION_CALL WriteLine ( expression )? )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(FUNCTION_CALL, "FUNCTION_CALL"), root_1);

                        adaptor.addChild(root_1, stream_WriteLine.nextNode());
                        // WJ.g:92:72: ( expression )?
                        if ( stream_expression.hasNext() ) {
                            adaptor.addChild(root_1, stream_expression.nextTree());

                        }
                        stream_expression.reset();

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 3 :
                    // WJ.g:93:4: ReadString ( '()' | '(' ')' )
                    {
                    ReadString40=(Token)match(input,ReadString,FOLLOW_ReadString_in_functionCall467);  
                    stream_ReadString.add(ReadString40);

                    // WJ.g:93:15: ( '()' | '(' ')' )
                    int alt12=2;
                    int LA12_0 = input.LA(1);

                    if ( (LA12_0==57) ) {
                        alt12=1;
                    }
                    else if ( (LA12_0==53) ) {
                        alt12=2;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("", 12, 0, input);

                        throw nvae;
                    }
                    switch (alt12) {
                        case 1 :
                            // WJ.g:93:16: '()'
                            {
                            string_literal41=(Token)match(input,57,FOLLOW_57_in_functionCall470);  
                            stream_57.add(string_literal41);


                            }
                            break;
                        case 2 :
                            // WJ.g:93:23: '(' ')'
                            {
                            char_literal42=(Token)match(input,53,FOLLOW_53_in_functionCall474);  
                            stream_53.add(char_literal42);

                            char_literal43=(Token)match(input,54,FOLLOW_54_in_functionCall476);  
                            stream_54.add(char_literal43);


                            }
                            break;

                    }



                    // AST REWRITE
                    // elements: ReadString
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 93:31: -> ^( FUNCTION_CALL ReadString )
                    {
                        // WJ.g:93:34: ^( FUNCTION_CALL ReadString )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(FUNCTION_CALL, "FUNCTION_CALL"), root_1);

                        adaptor.addChild(root_1, stream_ReadString.nextNode());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 4 :
                    // WJ.g:94:4: ReadNumber ( '()' | '(' ')' )
                    {
                    ReadNumber44=(Token)match(input,ReadNumber,FOLLOW_ReadNumber_in_functionCall489);  
                    stream_ReadNumber.add(ReadNumber44);

                    // WJ.g:94:15: ( '()' | '(' ')' )
                    int alt13=2;
                    int LA13_0 = input.LA(1);

                    if ( (LA13_0==57) ) {
                        alt13=1;
                    }
                    else if ( (LA13_0==53) ) {
                        alt13=2;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("", 13, 0, input);

                        throw nvae;
                    }
                    switch (alt13) {
                        case 1 :
                            // WJ.g:94:16: '()'
                            {
                            string_literal45=(Token)match(input,57,FOLLOW_57_in_functionCall492);  
                            stream_57.add(string_literal45);


                            }
                            break;
                        case 2 :
                            // WJ.g:94:23: '(' ')'
                            {
                            char_literal46=(Token)match(input,53,FOLLOW_53_in_functionCall496);  
                            stream_53.add(char_literal46);

                            char_literal47=(Token)match(input,54,FOLLOW_54_in_functionCall498);  
                            stream_54.add(char_literal47);


                            }
                            break;

                    }



                    // AST REWRITE
                    // elements: ReadNumber
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 94:31: -> ^( FUNCTION_CALL ReadNumber )
                    {
                        // WJ.g:94:34: ^( FUNCTION_CALL ReadNumber )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(FUNCTION_CALL, "FUNCTION_CALL"), root_1);

                        adaptor.addChild(root_1, stream_ReadNumber.nextNode());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 5 :
                    // WJ.g:95:4: Connect '(' expression ( ',' expression )+ ')'
                    {
                    Connect48=(Token)match(input,Connect,FOLLOW_Connect_in_functionCall511);  
                    stream_Connect.add(Connect48);

                    char_literal49=(Token)match(input,53,FOLLOW_53_in_functionCall513);  
                    stream_53.add(char_literal49);

                    pushFollow(FOLLOW_expression_in_functionCall515);
                    expression50=expression();

                    state._fsp--;

                    stream_expression.add(expression50.getTree());
                    // WJ.g:95:27: ( ',' expression )+
                    int cnt14=0;
                    loop14:
                    do {
                        int alt14=2;
                        int LA14_0 = input.LA(1);

                        if ( (LA14_0==56) ) {
                            alt14=1;
                        }


                        switch (alt14) {
                    	case 1 :
                    	    // WJ.g:95:28: ',' expression
                    	    {
                    	    char_literal51=(Token)match(input,56,FOLLOW_56_in_functionCall518);  
                    	    stream_56.add(char_literal51);

                    	    pushFollow(FOLLOW_expression_in_functionCall520);
                    	    expression52=expression();

                    	    state._fsp--;

                    	    stream_expression.add(expression52.getTree());

                    	    }
                    	    break;

                    	default :
                    	    if ( cnt14 >= 1 ) break loop14;
                                EarlyExitException eee =
                                    new EarlyExitException(14, input);
                                throw eee;
                        }
                        cnt14++;
                    } while (true);

                    char_literal53=(Token)match(input,54,FOLLOW_54_in_functionCall524);  
                    stream_54.add(char_literal53);



                    // AST REWRITE
                    // elements: expression, Connect
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 95:49: -> ^( FUNCTION_CALL Connect ( expression )+ )
                    {
                        // WJ.g:95:52: ^( FUNCTION_CALL Connect ( expression )+ )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(FUNCTION_CALL, "FUNCTION_CALL"), root_1);

                        adaptor.addChild(root_1, stream_Connect.nextNode());
                        if ( !(stream_expression.hasNext()) ) {
                            throw new RewriteEarlyExitException();
                        }
                        while ( stream_expression.hasNext() ) {
                            adaptor.addChild(root_1, stream_expression.nextTree());

                        }
                        stream_expression.reset();

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 6 :
                    // WJ.g:96:4: stringExpr Length
                    {
                    pushFollow(FOLLOW_stringExpr_in_functionCall540);
                    stringExpr54=stringExpr();

                    state._fsp--;

                    stream_stringExpr.add(stringExpr54.getTree());
                    Length55=(Token)match(input,Length,FOLLOW_Length_in_functionCall542);  
                    stream_Length.add(Length55);



                    // AST REWRITE
                    // elements: stringExpr, Length
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 96:22: -> ^( FUNCTION_CALL Length stringExpr )
                    {
                        // WJ.g:96:25: ^( FUNCTION_CALL Length stringExpr )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(FUNCTION_CALL, "FUNCTION_CALL"), root_1);

                        adaptor.addChild(root_1, stream_Length.nextNode());
                        adaptor.addChild(root_1, stream_stringExpr.nextTree());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 7 :
                    // WJ.g:97:4: stringExpr CharAt '[' expression ']'
                    {
                    pushFollow(FOLLOW_stringExpr_in_functionCall557);
                    stringExpr56=stringExpr();

                    state._fsp--;

                    stream_stringExpr.add(stringExpr56.getTree());
                    CharAt57=(Token)match(input,CharAt,FOLLOW_CharAt_in_functionCall559);  
                    stream_CharAt.add(CharAt57);

                    char_literal58=(Token)match(input,58,FOLLOW_58_in_functionCall561);  
                    stream_58.add(char_literal58);

                    pushFollow(FOLLOW_expression_in_functionCall563);
                    expression59=expression();

                    state._fsp--;

                    stream_expression.add(expression59.getTree());
                    char_literal60=(Token)match(input,59,FOLLOW_59_in_functionCall565);  
                    stream_59.add(char_literal60);



                    // AST REWRITE
                    // elements: stringExpr, expression, CharAt
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 97:41: -> ^( FUNCTION_CALL CharAt stringExpr expression )
                    {
                        // WJ.g:97:44: ^( FUNCTION_CALL CharAt stringExpr expression )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(FUNCTION_CALL, "FUNCTION_CALL"), root_1);

                        adaptor.addChild(root_1, stream_CharAt.nextNode());
                        adaptor.addChild(root_1, stream_stringExpr.nextTree());
                        adaptor.addChild(root_1, stream_expression.nextTree());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 8 :
                    // WJ.g:98:4: Take expression 'characters' 'from' stringExpr
                    {
                    Take61=(Token)match(input,Take,FOLLOW_Take_in_functionCall582);  
                    stream_Take.add(Take61);

                    pushFollow(FOLLOW_expression_in_functionCall584);
                    expression62=expression();

                    state._fsp--;

                    stream_expression.add(expression62.getTree());
                    string_literal63=(Token)match(input,60,FOLLOW_60_in_functionCall586);  
                    stream_60.add(string_literal63);

                    string_literal64=(Token)match(input,61,FOLLOW_61_in_functionCall588);  
                    stream_61.add(string_literal64);

                    pushFollow(FOLLOW_stringExpr_in_functionCall590);
                    stringExpr65=stringExpr();

                    state._fsp--;

                    stream_stringExpr.add(stringExpr65.getTree());


                    // AST REWRITE
                    // elements: expression, Take, stringExpr
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 98:51: -> ^( FUNCTION_CALL Take expression stringExpr )
                    {
                        // WJ.g:98:54: ^( FUNCTION_CALL Take expression stringExpr )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(FUNCTION_CALL, "FUNCTION_CALL"), root_1);

                        adaptor.addChild(root_1, stream_Take.nextNode());
                        adaptor.addChild(root_1, stream_expression.nextTree());
                        adaptor.addChild(root_1, stream_stringExpr.nextTree());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 9 :
                    // WJ.g:99:4: Drop expression 'characters' 'from' stringExpr
                    {
                    Drop66=(Token)match(input,Drop,FOLLOW_Drop_in_functionCall607);  
                    stream_Drop.add(Drop66);

                    pushFollow(FOLLOW_expression_in_functionCall609);
                    expression67=expression();

                    state._fsp--;

                    stream_expression.add(expression67.getTree());
                    string_literal68=(Token)match(input,60,FOLLOW_60_in_functionCall611);  
                    stream_60.add(string_literal68);

                    string_literal69=(Token)match(input,61,FOLLOW_61_in_functionCall613);  
                    stream_61.add(string_literal69);

                    pushFollow(FOLLOW_stringExpr_in_functionCall615);
                    stringExpr70=stringExpr();

                    state._fsp--;

                    stream_stringExpr.add(stringExpr70.getTree());


                    // AST REWRITE
                    // elements: Drop, stringExpr, expression
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 99:51: -> ^( FUNCTION_CALL Drop expression stringExpr )
                    {
                        // WJ.g:99:54: ^( FUNCTION_CALL Drop expression stringExpr )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(FUNCTION_CALL, "FUNCTION_CALL"), root_1);

                        adaptor.addChild(root_1, stream_Drop.nextNode());
                        adaptor.addChild(root_1, stream_expression.nextTree());
                        adaptor.addChild(root_1, stream_stringExpr.nextTree());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 10 :
                    // WJ.g:100:4: Identifier ( '()' | '(' ( argumentList )? ')' )
                    {
                    Identifier71=(Token)match(input,Identifier,FOLLOW_Identifier_in_functionCall632);  
                    stream_Identifier.add(Identifier71);

                    // WJ.g:100:15: ( '()' | '(' ( argumentList )? ')' )
                    int alt16=2;
                    int LA16_0 = input.LA(1);

                    if ( (LA16_0==57) ) {
                        alt16=1;
                    }
                    else if ( (LA16_0==53) ) {
                        alt16=2;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("", 16, 0, input);

                        throw nvae;
                    }
                    switch (alt16) {
                        case 1 :
                            // WJ.g:100:16: '()'
                            {
                            string_literal72=(Token)match(input,57,FOLLOW_57_in_functionCall635);  
                            stream_57.add(string_literal72);


                            }
                            break;
                        case 2 :
                            // WJ.g:100:23: '(' ( argumentList )? ')'
                            {
                            char_literal73=(Token)match(input,53,FOLLOW_53_in_functionCall639);  
                            stream_53.add(char_literal73);

                            // WJ.g:100:26: ( argumentList )?
                            int alt15=2;
                            int LA15_0 = input.LA(1);

                            if ( (LA15_0==Identifier||(LA15_0>=Write && LA15_0<=Connect)||(LA15_0>=Take && LA15_0<=String)||(LA15_0>=Number && LA15_0<=Boolean)||LA15_0==53||LA15_0==76||LA15_0==81) ) {
                                alt15=1;
                            }
                            switch (alt15) {
                                case 1 :
                                    // WJ.g:100:26: argumentList
                                    {
                                    pushFollow(FOLLOW_argumentList_in_functionCall640);
                                    argumentList74=argumentList();

                                    state._fsp--;

                                    stream_argumentList.add(argumentList74.getTree());

                                    }
                                    break;

                            }

                            char_literal75=(Token)match(input,54,FOLLOW_54_in_functionCall642);  
                            stream_54.add(char_literal75);


                            }
                            break;

                    }



                    // AST REWRITE
                    // elements: Identifier, argumentList
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 100:44: -> ^( FUNCTION_CALL Identifier ( argumentList )? )
                    {
                        // WJ.g:100:47: ^( FUNCTION_CALL Identifier ( argumentList )? )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(FUNCTION_CALL, "FUNCTION_CALL"), root_1);

                        adaptor.addChild(root_1, stream_Identifier.nextNode());
                        // WJ.g:100:74: ( argumentList )?
                        if ( stream_argumentList.hasNext() ) {
                            adaptor.addChild(root_1, stream_argumentList.nextTree());

                        }
                        stream_argumentList.reset();

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;

            }
            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "functionCall"

    public static class stringExpr_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "stringExpr"
    // WJ.g:103:1: stringExpr : ( String | Identifier );
    public final WJParser.stringExpr_return stringExpr() throws RecognitionException {
        WJParser.stringExpr_return retval = new WJParser.stringExpr_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token set76=null;

        Object set76_tree=null;

        try {
            // WJ.g:104:2: ( String | Identifier )
            // WJ.g:
            {
            root_0 = (Object)adaptor.nil();

            set76=(Token)input.LT(1);
            if ( input.LA(1)==Identifier||input.LA(1)==String ) {
                input.consume();
                adaptor.addChild(root_0, (Object)adaptor.create(set76));
                state.errorRecovery=false;
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "stringExpr"

    public static class ifStatement_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "ifStatement"
    // WJ.g:108:1: ifStatement : ifStatementPart ( elseIfStatementPart )* ( elseStatementPart )? EndIf -> ^( IF ifStatementPart ( elseIfStatementPart )* ( elseStatementPart )? ) ;
    public final WJParser.ifStatement_return ifStatement() throws RecognitionException {
        WJParser.ifStatement_return retval = new WJParser.ifStatement_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token EndIf80=null;
        WJParser.ifStatementPart_return ifStatementPart77 = null;

        WJParser.elseIfStatementPart_return elseIfStatementPart78 = null;

        WJParser.elseStatementPart_return elseStatementPart79 = null;


        Object EndIf80_tree=null;
        RewriteRuleTokenStream stream_EndIf=new RewriteRuleTokenStream(adaptor,"token EndIf");
        RewriteRuleSubtreeStream stream_elseStatementPart=new RewriteRuleSubtreeStream(adaptor,"rule elseStatementPart");
        RewriteRuleSubtreeStream stream_ifStatementPart=new RewriteRuleSubtreeStream(adaptor,"rule ifStatementPart");
        RewriteRuleSubtreeStream stream_elseIfStatementPart=new RewriteRuleSubtreeStream(adaptor,"rule elseIfStatementPart");
        try {
            // WJ.g:109:2: ( ifStatementPart ( elseIfStatementPart )* ( elseStatementPart )? EndIf -> ^( IF ifStatementPart ( elseIfStatementPart )* ( elseStatementPart )? ) )
            // WJ.g:109:5: ifStatementPart ( elseIfStatementPart )* ( elseStatementPart )? EndIf
            {
            pushFollow(FOLLOW_ifStatementPart_in_ifStatement684);
            ifStatementPart77=ifStatementPart();

            state._fsp--;

            stream_ifStatementPart.add(ifStatementPart77.getTree());
            // WJ.g:109:21: ( elseIfStatementPart )*
            loop18:
            do {
                int alt18=2;
                int LA18_0 = input.LA(1);

                if ( (LA18_0==ElseIf) ) {
                    alt18=1;
                }


                switch (alt18) {
            	case 1 :
            	    // WJ.g:109:21: elseIfStatementPart
            	    {
            	    pushFollow(FOLLOW_elseIfStatementPart_in_ifStatement686);
            	    elseIfStatementPart78=elseIfStatementPart();

            	    state._fsp--;

            	    stream_elseIfStatementPart.add(elseIfStatementPart78.getTree());

            	    }
            	    break;

            	default :
            	    break loop18;
                }
            } while (true);

            // WJ.g:109:42: ( elseStatementPart )?
            int alt19=2;
            int LA19_0 = input.LA(1);

            if ( (LA19_0==Else) ) {
                alt19=1;
            }
            switch (alt19) {
                case 1 :
                    // WJ.g:109:42: elseStatementPart
                    {
                    pushFollow(FOLLOW_elseStatementPart_in_ifStatement689);
                    elseStatementPart79=elseStatementPart();

                    state._fsp--;

                    stream_elseStatementPart.add(elseStatementPart79.getTree());

                    }
                    break;

            }

            EndIf80=(Token)match(input,EndIf,FOLLOW_EndIf_in_ifStatement692);  
            stream_EndIf.add(EndIf80);



            // AST REWRITE
            // elements: elseStatementPart, ifStatementPart, elseIfStatementPart
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 109:67: -> ^( IF ifStatementPart ( elseIfStatementPart )* ( elseStatementPart )? )
            {
                // WJ.g:109:70: ^( IF ifStatementPart ( elseIfStatementPart )* ( elseStatementPart )? )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(IF, "IF"), root_1);

                adaptor.addChild(root_1, stream_ifStatementPart.nextTree());
                // WJ.g:109:91: ( elseIfStatementPart )*
                while ( stream_elseIfStatementPart.hasNext() ) {
                    adaptor.addChild(root_1, stream_elseIfStatementPart.nextTree());

                }
                stream_elseIfStatementPart.reset();
                // WJ.g:109:112: ( elseStatementPart )?
                if ( stream_elseStatementPart.hasNext() ) {
                    adaptor.addChild(root_1, stream_elseStatementPart.nextTree());

                }
                stream_elseStatementPart.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "ifStatement"

    public static class ifStatementPart_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "ifStatementPart"
    // WJ.g:112:1: ifStatementPart : If expression 'then' ':' block -> ^( IF expression block ) ;
    public final WJParser.ifStatementPart_return ifStatementPart() throws RecognitionException {
        WJParser.ifStatementPart_return retval = new WJParser.ifStatementPart_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token If81=null;
        Token string_literal83=null;
        Token char_literal84=null;
        WJParser.expression_return expression82 = null;

        WJParser.block_return block85 = null;


        Object If81_tree=null;
        Object string_literal83_tree=null;
        Object char_literal84_tree=null;
        RewriteRuleTokenStream stream_55=new RewriteRuleTokenStream(adaptor,"token 55");
        RewriteRuleTokenStream stream_62=new RewriteRuleTokenStream(adaptor,"token 62");
        RewriteRuleTokenStream stream_If=new RewriteRuleTokenStream(adaptor,"token If");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        RewriteRuleSubtreeStream stream_block=new RewriteRuleSubtreeStream(adaptor,"rule block");
        try {
            // WJ.g:113:2: ( If expression 'then' ':' block -> ^( IF expression block ) )
            // WJ.g:113:4: If expression 'then' ':' block
            {
            If81=(Token)match(input,If,FOLLOW_If_in_ifStatementPart719);  
            stream_If.add(If81);

            pushFollow(FOLLOW_expression_in_ifStatementPart721);
            expression82=expression();

            state._fsp--;

            stream_expression.add(expression82.getTree());
            string_literal83=(Token)match(input,62,FOLLOW_62_in_ifStatementPart723);  
            stream_62.add(string_literal83);

            char_literal84=(Token)match(input,55,FOLLOW_55_in_ifStatementPart725);  
            stream_55.add(char_literal84);

            pushFollow(FOLLOW_block_in_ifStatementPart727);
            block85=block();

            state._fsp--;

            stream_block.add(block85.getTree());


            // AST REWRITE
            // elements: expression, block
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 113:35: -> ^( IF expression block )
            {
                // WJ.g:113:38: ^( IF expression block )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(IF, "IF"), root_1);

                adaptor.addChild(root_1, stream_expression.nextTree());
                adaptor.addChild(root_1, stream_block.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "ifStatementPart"

    public static class elseIfStatementPart_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "elseIfStatementPart"
    // WJ.g:116:1: elseIfStatementPart : ElseIf expression 'then' ':' block -> ^( ELSE_IF expression block ) ;
    public final WJParser.elseIfStatementPart_return elseIfStatementPart() throws RecognitionException {
        WJParser.elseIfStatementPart_return retval = new WJParser.elseIfStatementPart_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token ElseIf86=null;
        Token string_literal88=null;
        Token char_literal89=null;
        WJParser.expression_return expression87 = null;

        WJParser.block_return block90 = null;


        Object ElseIf86_tree=null;
        Object string_literal88_tree=null;
        Object char_literal89_tree=null;
        RewriteRuleTokenStream stream_ElseIf=new RewriteRuleTokenStream(adaptor,"token ElseIf");
        RewriteRuleTokenStream stream_55=new RewriteRuleTokenStream(adaptor,"token 55");
        RewriteRuleTokenStream stream_62=new RewriteRuleTokenStream(adaptor,"token 62");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        RewriteRuleSubtreeStream stream_block=new RewriteRuleSubtreeStream(adaptor,"rule block");
        try {
            // WJ.g:117:2: ( ElseIf expression 'then' ':' block -> ^( ELSE_IF expression block ) )
            // WJ.g:117:4: ElseIf expression 'then' ':' block
            {
            ElseIf86=(Token)match(input,ElseIf,FOLLOW_ElseIf_in_elseIfStatementPart749);  
            stream_ElseIf.add(ElseIf86);

            pushFollow(FOLLOW_expression_in_elseIfStatementPart751);
            expression87=expression();

            state._fsp--;

            stream_expression.add(expression87.getTree());
            string_literal88=(Token)match(input,62,FOLLOW_62_in_elseIfStatementPart753);  
            stream_62.add(string_literal88);

            char_literal89=(Token)match(input,55,FOLLOW_55_in_elseIfStatementPart755);  
            stream_55.add(char_literal89);

            pushFollow(FOLLOW_block_in_elseIfStatementPart757);
            block90=block();

            state._fsp--;

            stream_block.add(block90.getTree());


            // AST REWRITE
            // elements: block, expression
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 117:39: -> ^( ELSE_IF expression block )
            {
                // WJ.g:117:42: ^( ELSE_IF expression block )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(ELSE_IF, "ELSE_IF"), root_1);

                adaptor.addChild(root_1, stream_expression.nextTree());
                adaptor.addChild(root_1, stream_block.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "elseIfStatementPart"

    public static class elseStatementPart_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "elseStatementPart"
    // WJ.g:120:1: elseStatementPart : Else ':' block -> ^( ELSE block ) ;
    public final WJParser.elseStatementPart_return elseStatementPart() throws RecognitionException {
        WJParser.elseStatementPart_return retval = new WJParser.elseStatementPart_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token Else91=null;
        Token char_literal92=null;
        WJParser.block_return block93 = null;


        Object Else91_tree=null;
        Object char_literal92_tree=null;
        RewriteRuleTokenStream stream_55=new RewriteRuleTokenStream(adaptor,"token 55");
        RewriteRuleTokenStream stream_Else=new RewriteRuleTokenStream(adaptor,"token Else");
        RewriteRuleSubtreeStream stream_block=new RewriteRuleSubtreeStream(adaptor,"rule block");
        try {
            // WJ.g:121:2: ( Else ':' block -> ^( ELSE block ) )
            // WJ.g:121:4: Else ':' block
            {
            Else91=(Token)match(input,Else,FOLLOW_Else_in_elseStatementPart779);  
            stream_Else.add(Else91);

            char_literal92=(Token)match(input,55,FOLLOW_55_in_elseStatementPart781);  
            stream_55.add(char_literal92);

            pushFollow(FOLLOW_block_in_elseStatementPart783);
            block93=block();

            state._fsp--;

            stream_block.add(block93.getTree());


            // AST REWRITE
            // elements: block
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 121:19: -> ^( ELSE block )
            {
                // WJ.g:121:22: ^( ELSE block )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(ELSE, "ELSE"), root_1);

                adaptor.addChild(root_1, stream_block.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "elseStatementPart"

    public static class whileStatement_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "whileStatement"
    // WJ.g:124:1: whileStatement : 'while' expression 'is' 'correct' ':' block 'end while' ;
    public final WJParser.whileStatement_return whileStatement() throws RecognitionException {
        WJParser.whileStatement_return retval = new WJParser.whileStatement_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token string_literal94=null;
        Token string_literal96=null;
        Token string_literal97=null;
        Token char_literal98=null;
        Token string_literal100=null;
        WJParser.expression_return expression95 = null;

        WJParser.block_return block99 = null;


        Object string_literal94_tree=null;
        Object string_literal96_tree=null;
        Object string_literal97_tree=null;
        Object char_literal98_tree=null;
        Object string_literal100_tree=null;

        try {
            // WJ.g:125:2: ( 'while' expression 'is' 'correct' ':' block 'end while' )
            // WJ.g:125:4: 'while' expression 'is' 'correct' ':' block 'end while'
            {
            root_0 = (Object)adaptor.nil();

            string_literal94=(Token)match(input,63,FOLLOW_63_in_whileStatement803); 
            string_literal94_tree = (Object)adaptor.create(string_literal94);
            root_0 = (Object)adaptor.becomeRoot(string_literal94_tree, root_0);

            pushFollow(FOLLOW_expression_in_whileStatement806);
            expression95=expression();

            state._fsp--;

            adaptor.addChild(root_0, expression95.getTree());
            string_literal96=(Token)match(input,64,FOLLOW_64_in_whileStatement808); 
            string_literal96_tree = (Object)adaptor.create(string_literal96);
            adaptor.addChild(root_0, string_literal96_tree);

            string_literal97=(Token)match(input,65,FOLLOW_65_in_whileStatement810); 
            string_literal97_tree = (Object)adaptor.create(string_literal97);
            adaptor.addChild(root_0, string_literal97_tree);

            char_literal98=(Token)match(input,55,FOLLOW_55_in_whileStatement812); 
            char_literal98_tree = (Object)adaptor.create(char_literal98);
            adaptor.addChild(root_0, char_literal98_tree);

            pushFollow(FOLLOW_block_in_whileStatement814);
            block99=block();

            state._fsp--;

            adaptor.addChild(root_0, block99.getTree());
            string_literal100=(Token)match(input,66,FOLLOW_66_in_whileStatement816); 
            string_literal100_tree = (Object)adaptor.create(string_literal100);
            adaptor.addChild(root_0, string_literal100_tree);


            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "whileStatement"

    public static class expression_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "expression"
    // WJ.g:128:1: expression : andExpr ( 'or' andExpr )* -> ^( OR ( andExpr )+ ) ;
    public final WJParser.expression_return expression() throws RecognitionException {
        WJParser.expression_return retval = new WJParser.expression_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token string_literal102=null;
        WJParser.andExpr_return andExpr101 = null;

        WJParser.andExpr_return andExpr103 = null;


        Object string_literal102_tree=null;
        RewriteRuleTokenStream stream_67=new RewriteRuleTokenStream(adaptor,"token 67");
        RewriteRuleSubtreeStream stream_andExpr=new RewriteRuleSubtreeStream(adaptor,"rule andExpr");
        try {
            // WJ.g:129:2: ( andExpr ( 'or' andExpr )* -> ^( OR ( andExpr )+ ) )
            // WJ.g:129:4: andExpr ( 'or' andExpr )*
            {
            pushFollow(FOLLOW_andExpr_in_expression828);
            andExpr101=andExpr();

            state._fsp--;

            stream_andExpr.add(andExpr101.getTree());
            // WJ.g:129:12: ( 'or' andExpr )*
            loop20:
            do {
                int alt20=2;
                int LA20_0 = input.LA(1);

                if ( (LA20_0==67) ) {
                    alt20=1;
                }


                switch (alt20) {
            	case 1 :
            	    // WJ.g:129:13: 'or' andExpr
            	    {
            	    string_literal102=(Token)match(input,67,FOLLOW_67_in_expression831);  
            	    stream_67.add(string_literal102);

            	    pushFollow(FOLLOW_andExpr_in_expression833);
            	    andExpr103=andExpr();

            	    state._fsp--;

            	    stream_andExpr.add(andExpr103.getTree());

            	    }
            	    break;

            	default :
            	    break loop20;
                }
            } while (true);



            // AST REWRITE
            // elements: andExpr
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 129:28: -> ^( OR ( andExpr )+ )
            {
                // WJ.g:129:31: ^( OR ( andExpr )+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(OR, "OR"), root_1);

                if ( !(stream_andExpr.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_andExpr.hasNext() ) {
                    adaptor.addChild(root_1, stream_andExpr.nextTree());

                }
                stream_andExpr.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "expression"

    public static class andExpr_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "andExpr"
    // WJ.g:132:1: andExpr : relExpr ( 'and' relExpr )* -> ^( AND ( relExpr )+ ) ;
    public final WJParser.andExpr_return andExpr() throws RecognitionException {
        WJParser.andExpr_return retval = new WJParser.andExpr_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token string_literal105=null;
        WJParser.relExpr_return relExpr104 = null;

        WJParser.relExpr_return relExpr106 = null;


        Object string_literal105_tree=null;
        RewriteRuleTokenStream stream_68=new RewriteRuleTokenStream(adaptor,"token 68");
        RewriteRuleSubtreeStream stream_relExpr=new RewriteRuleSubtreeStream(adaptor,"rule relExpr");
        try {
            // WJ.g:133:2: ( relExpr ( 'and' relExpr )* -> ^( AND ( relExpr )+ ) )
            // WJ.g:133:4: relExpr ( 'and' relExpr )*
            {
            pushFollow(FOLLOW_relExpr_in_andExpr855);
            relExpr104=relExpr();

            state._fsp--;

            stream_relExpr.add(relExpr104.getTree());
            // WJ.g:133:12: ( 'and' relExpr )*
            loop21:
            do {
                int alt21=2;
                int LA21_0 = input.LA(1);

                if ( (LA21_0==68) ) {
                    alt21=1;
                }


                switch (alt21) {
            	case 1 :
            	    // WJ.g:133:13: 'and' relExpr
            	    {
            	    string_literal105=(Token)match(input,68,FOLLOW_68_in_andExpr858);  
            	    stream_68.add(string_literal105);

            	    pushFollow(FOLLOW_relExpr_in_andExpr860);
            	    relExpr106=relExpr();

            	    state._fsp--;

            	    stream_relExpr.add(relExpr106.getTree());

            	    }
            	    break;

            	default :
            	    break loop21;
                }
            } while (true);



            // AST REWRITE
            // elements: relExpr
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 133:29: -> ^( AND ( relExpr )+ )
            {
                // WJ.g:133:32: ^( AND ( relExpr )+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(AND, "AND"), root_1);

                if ( !(stream_relExpr.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_relExpr.hasNext() ) {
                    adaptor.addChild(root_1, stream_relExpr.nextTree());

                }
                stream_relExpr.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "andExpr"

    public static class relExpr_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "relExpr"
    // WJ.g:136:1: relExpr : arimExpr ( relOp arimExpr )? -> ^( RELATIONAL ( relOp )? ( arimExpr )+ ) ;
    public final WJParser.relExpr_return relExpr() throws RecognitionException {
        WJParser.relExpr_return retval = new WJParser.relExpr_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        WJParser.arimExpr_return arimExpr107 = null;

        WJParser.relOp_return relOp108 = null;

        WJParser.arimExpr_return arimExpr109 = null;


        RewriteRuleSubtreeStream stream_relOp=new RewriteRuleSubtreeStream(adaptor,"rule relOp");
        RewriteRuleSubtreeStream stream_arimExpr=new RewriteRuleSubtreeStream(adaptor,"rule arimExpr");
        try {
            // WJ.g:137:2: ( arimExpr ( relOp arimExpr )? -> ^( RELATIONAL ( relOp )? ( arimExpr )+ ) )
            // WJ.g:137:5: arimExpr ( relOp arimExpr )?
            {
            pushFollow(FOLLOW_arimExpr_in_relExpr883);
            arimExpr107=arimExpr();

            state._fsp--;

            stream_arimExpr.add(arimExpr107.getTree());
            // WJ.g:137:14: ( relOp arimExpr )?
            int alt22=2;
            int LA22_0 = input.LA(1);

            if ( ((LA22_0>=69 && LA22_0<=74)) ) {
                alt22=1;
            }
            switch (alt22) {
                case 1 :
                    // WJ.g:137:15: relOp arimExpr
                    {
                    pushFollow(FOLLOW_relOp_in_relExpr886);
                    relOp108=relOp();

                    state._fsp--;

                    stream_relOp.add(relOp108.getTree());
                    pushFollow(FOLLOW_arimExpr_in_relExpr888);
                    arimExpr109=arimExpr();

                    state._fsp--;

                    stream_arimExpr.add(arimExpr109.getTree());

                    }
                    break;

            }



            // AST REWRITE
            // elements: arimExpr, relOp
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 137:32: -> ^( RELATIONAL ( relOp )? ( arimExpr )+ )
            {
                // WJ.g:137:35: ^( RELATIONAL ( relOp )? ( arimExpr )+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(RELATIONAL, "RELATIONAL"), root_1);

                // WJ.g:137:48: ( relOp )?
                if ( stream_relOp.hasNext() ) {
                    adaptor.addChild(root_1, stream_relOp.nextTree());

                }
                stream_relOp.reset();
                if ( !(stream_arimExpr.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_arimExpr.hasNext() ) {
                    adaptor.addChild(root_1, stream_arimExpr.nextTree());

                }
                stream_arimExpr.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "relExpr"

    public static class relOp_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "relOp"
    // WJ.g:140:1: relOp : ( '==' | '!=' | '>=' | '<=' | '>' | '<' );
    public final WJParser.relOp_return relOp() throws RecognitionException {
        WJParser.relOp_return retval = new WJParser.relOp_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token set110=null;

        Object set110_tree=null;

        try {
            // WJ.g:141:2: ( '==' | '!=' | '>=' | '<=' | '>' | '<' )
            // WJ.g:
            {
            root_0 = (Object)adaptor.nil();

            set110=(Token)input.LT(1);
            if ( (input.LA(1)>=69 && input.LA(1)<=74) ) {
                input.consume();
                adaptor.addChild(root_0, (Object)adaptor.create(set110));
                state.errorRecovery=false;
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "relOp"

    public static class arimExpr_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "arimExpr"
    // WJ.g:149:1: arimExpr : mulExpr ( addSub mulExpr )* -> ^( ADDSUB ( addSub )* ( mulExpr )+ ) ;
    public final WJParser.arimExpr_return arimExpr() throws RecognitionException {
        WJParser.arimExpr_return retval = new WJParser.arimExpr_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        WJParser.mulExpr_return mulExpr111 = null;

        WJParser.addSub_return addSub112 = null;

        WJParser.mulExpr_return mulExpr113 = null;


        RewriteRuleSubtreeStream stream_addSub=new RewriteRuleSubtreeStream(adaptor,"rule addSub");
        RewriteRuleSubtreeStream stream_mulExpr=new RewriteRuleSubtreeStream(adaptor,"rule mulExpr");
        try {
            // WJ.g:150:2: ( mulExpr ( addSub mulExpr )* -> ^( ADDSUB ( addSub )* ( mulExpr )+ ) )
            // WJ.g:150:4: mulExpr ( addSub mulExpr )*
            {
            pushFollow(FOLLOW_mulExpr_in_arimExpr960);
            mulExpr111=mulExpr();

            state._fsp--;

            stream_mulExpr.add(mulExpr111.getTree());
            // WJ.g:150:12: ( addSub mulExpr )*
            loop23:
            do {
                int alt23=2;
                int LA23_0 = input.LA(1);

                if ( ((LA23_0>=75 && LA23_0<=76)) ) {
                    alt23=1;
                }


                switch (alt23) {
            	case 1 :
            	    // WJ.g:150:13: addSub mulExpr
            	    {
            	    pushFollow(FOLLOW_addSub_in_arimExpr963);
            	    addSub112=addSub();

            	    state._fsp--;

            	    stream_addSub.add(addSub112.getTree());
            	    pushFollow(FOLLOW_mulExpr_in_arimExpr965);
            	    mulExpr113=mulExpr();

            	    state._fsp--;

            	    stream_mulExpr.add(mulExpr113.getTree());

            	    }
            	    break;

            	default :
            	    break loop23;
                }
            } while (true);



            // AST REWRITE
            // elements: mulExpr, addSub
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 150:30: -> ^( ADDSUB ( addSub )* ( mulExpr )+ )
            {
                // WJ.g:150:33: ^( ADDSUB ( addSub )* ( mulExpr )+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(ADDSUB, "ADDSUB"), root_1);

                // WJ.g:150:42: ( addSub )*
                while ( stream_addSub.hasNext() ) {
                    adaptor.addChild(root_1, stream_addSub.nextTree());

                }
                stream_addSub.reset();
                if ( !(stream_mulExpr.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_mulExpr.hasNext() ) {
                    adaptor.addChild(root_1, stream_mulExpr.nextTree());

                }
                stream_mulExpr.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "arimExpr"

    public static class addSub_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "addSub"
    // WJ.g:153:1: addSub : ( '+' | '-' );
    public final WJParser.addSub_return addSub() throws RecognitionException {
        WJParser.addSub_return retval = new WJParser.addSub_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token set114=null;

        Object set114_tree=null;

        try {
            // WJ.g:154:2: ( '+' | '-' )
            // WJ.g:
            {
            root_0 = (Object)adaptor.nil();

            set114=(Token)input.LT(1);
            if ( (input.LA(1)>=75 && input.LA(1)<=76) ) {
                input.consume();
                adaptor.addChild(root_0, (Object)adaptor.create(set114));
                state.errorRecovery=false;
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "addSub"

    public static class mulExpr_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "mulExpr"
    // WJ.g:158:1: mulExpr : powExpr ( mulDivMod powExpr )* -> ^( MULDIVMOD ( mulDivMod )* ( powExpr )+ ) ;
    public final WJParser.mulExpr_return mulExpr() throws RecognitionException {
        WJParser.mulExpr_return retval = new WJParser.mulExpr_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        WJParser.powExpr_return powExpr115 = null;

        WJParser.mulDivMod_return mulDivMod116 = null;

        WJParser.powExpr_return powExpr117 = null;


        RewriteRuleSubtreeStream stream_mulDivMod=new RewriteRuleSubtreeStream(adaptor,"rule mulDivMod");
        RewriteRuleSubtreeStream stream_powExpr=new RewriteRuleSubtreeStream(adaptor,"rule powExpr");
        try {
            // WJ.g:159:2: ( powExpr ( mulDivMod powExpr )* -> ^( MULDIVMOD ( mulDivMod )* ( powExpr )+ ) )
            // WJ.g:159:4: powExpr ( mulDivMod powExpr )*
            {
            pushFollow(FOLLOW_powExpr_in_mulExpr1014);
            powExpr115=powExpr();

            state._fsp--;

            stream_powExpr.add(powExpr115.getTree());
            // WJ.g:159:12: ( mulDivMod powExpr )*
            loop24:
            do {
                int alt24=2;
                int LA24_0 = input.LA(1);

                if ( ((LA24_0>=77 && LA24_0<=79)) ) {
                    alt24=1;
                }


                switch (alt24) {
            	case 1 :
            	    // WJ.g:159:13: mulDivMod powExpr
            	    {
            	    pushFollow(FOLLOW_mulDivMod_in_mulExpr1017);
            	    mulDivMod116=mulDivMod();

            	    state._fsp--;

            	    stream_mulDivMod.add(mulDivMod116.getTree());
            	    pushFollow(FOLLOW_powExpr_in_mulExpr1019);
            	    powExpr117=powExpr();

            	    state._fsp--;

            	    stream_powExpr.add(powExpr117.getTree());

            	    }
            	    break;

            	default :
            	    break loop24;
                }
            } while (true);



            // AST REWRITE
            // elements: powExpr, mulDivMod
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 159:33: -> ^( MULDIVMOD ( mulDivMod )* ( powExpr )+ )
            {
                // WJ.g:159:36: ^( MULDIVMOD ( mulDivMod )* ( powExpr )+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(MULDIVMOD, "MULDIVMOD"), root_1);

                // WJ.g:159:48: ( mulDivMod )*
                while ( stream_mulDivMod.hasNext() ) {
                    adaptor.addChild(root_1, stream_mulDivMod.nextTree());

                }
                stream_mulDivMod.reset();
                if ( !(stream_powExpr.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_powExpr.hasNext() ) {
                    adaptor.addChild(root_1, stream_powExpr.nextTree());

                }
                stream_powExpr.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "mulExpr"

    public static class mulDivMod_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "mulDivMod"
    // WJ.g:162:1: mulDivMod : ( '*' | '/' | 'mod' );
    public final WJParser.mulDivMod_return mulDivMod() throws RecognitionException {
        WJParser.mulDivMod_return retval = new WJParser.mulDivMod_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token set118=null;

        Object set118_tree=null;

        try {
            // WJ.g:163:2: ( '*' | '/' | 'mod' )
            // WJ.g:
            {
            root_0 = (Object)adaptor.nil();

            set118=(Token)input.LT(1);
            if ( (input.LA(1)>=77 && input.LA(1)<=79) ) {
                input.consume();
                adaptor.addChild(root_0, (Object)adaptor.create(set118));
                state.errorRecovery=false;
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "mulDivMod"

    public static class powExpr_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "powExpr"
    // WJ.g:168:1: powExpr : unaryExpr ( '^' unaryExpr )* -> ^( POW ( unaryExpr )+ ) ;
    public final WJParser.powExpr_return powExpr() throws RecognitionException {
        WJParser.powExpr_return retval = new WJParser.powExpr_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token char_literal120=null;
        WJParser.unaryExpr_return unaryExpr119 = null;

        WJParser.unaryExpr_return unaryExpr121 = null;


        Object char_literal120_tree=null;
        RewriteRuleTokenStream stream_80=new RewriteRuleTokenStream(adaptor,"token 80");
        RewriteRuleSubtreeStream stream_unaryExpr=new RewriteRuleSubtreeStream(adaptor,"rule unaryExpr");
        try {
            // WJ.g:169:2: ( unaryExpr ( '^' unaryExpr )* -> ^( POW ( unaryExpr )+ ) )
            // WJ.g:169:4: unaryExpr ( '^' unaryExpr )*
            {
            pushFollow(FOLLOW_unaryExpr_in_powExpr1072);
            unaryExpr119=unaryExpr();

            state._fsp--;

            stream_unaryExpr.add(unaryExpr119.getTree());
            // WJ.g:169:14: ( '^' unaryExpr )*
            loop25:
            do {
                int alt25=2;
                int LA25_0 = input.LA(1);

                if ( (LA25_0==80) ) {
                    alt25=1;
                }


                switch (alt25) {
            	case 1 :
            	    // WJ.g:169:15: '^' unaryExpr
            	    {
            	    char_literal120=(Token)match(input,80,FOLLOW_80_in_powExpr1075);  
            	    stream_80.add(char_literal120);

            	    pushFollow(FOLLOW_unaryExpr_in_powExpr1077);
            	    unaryExpr121=unaryExpr();

            	    state._fsp--;

            	    stream_unaryExpr.add(unaryExpr121.getTree());

            	    }
            	    break;

            	default :
            	    break loop25;
                }
            } while (true);



            // AST REWRITE
            // elements: unaryExpr
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 169:31: -> ^( POW ( unaryExpr )+ )
            {
                // WJ.g:169:34: ^( POW ( unaryExpr )+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(POW, "POW"), root_1);

                if ( !(stream_unaryExpr.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_unaryExpr.hasNext() ) {
                    adaptor.addChild(root_1, stream_unaryExpr.nextTree());

                }
                stream_unaryExpr.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "powExpr"

    public static class unaryExpr_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "unaryExpr"
    // WJ.g:172:1: unaryExpr : ( '-' atom | '!' atom | atom );
    public final WJParser.unaryExpr_return unaryExpr() throws RecognitionException {
        WJParser.unaryExpr_return retval = new WJParser.unaryExpr_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token char_literal122=null;
        Token char_literal124=null;
        WJParser.atom_return atom123 = null;

        WJParser.atom_return atom125 = null;

        WJParser.atom_return atom126 = null;


        Object char_literal122_tree=null;
        Object char_literal124_tree=null;

        try {
            // WJ.g:173:2: ( '-' atom | '!' atom | atom )
            int alt26=3;
            switch ( input.LA(1) ) {
            case 76:
                {
                alt26=1;
                }
                break;
            case 81:
                {
                alt26=2;
                }
                break;
            case Identifier:
            case Write:
            case WriteLine:
            case ReadString:
            case ReadNumber:
            case Connect:
            case Take:
            case Drop:
            case String:
            case Number:
            case Boolean:
            case 53:
                {
                alt26=3;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 26, 0, input);

                throw nvae;
            }

            switch (alt26) {
                case 1 :
                    // WJ.g:173:4: '-' atom
                    {
                    root_0 = (Object)adaptor.nil();

                    char_literal122=(Token)match(input,76,FOLLOW_76_in_unaryExpr1101); 
                    char_literal122_tree = (Object)adaptor.create(char_literal122);
                    root_0 = (Object)adaptor.becomeRoot(char_literal122_tree, root_0);

                    pushFollow(FOLLOW_atom_in_unaryExpr1104);
                    atom123=atom();

                    state._fsp--;

                    adaptor.addChild(root_0, atom123.getTree());

                    }
                    break;
                case 2 :
                    // WJ.g:174:4: '!' atom
                    {
                    root_0 = (Object)adaptor.nil();

                    char_literal124=(Token)match(input,81,FOLLOW_81_in_unaryExpr1109); 
                    char_literal124_tree = (Object)adaptor.create(char_literal124);
                    root_0 = (Object)adaptor.becomeRoot(char_literal124_tree, root_0);

                    pushFollow(FOLLOW_atom_in_unaryExpr1112);
                    atom125=atom();

                    state._fsp--;

                    adaptor.addChild(root_0, atom125.getTree());

                    }
                    break;
                case 3 :
                    // WJ.g:175:4: atom
                    {
                    root_0 = (Object)adaptor.nil();

                    pushFollow(FOLLOW_atom_in_unaryExpr1117);
                    atom126=atom();

                    state._fsp--;

                    adaptor.addChild(root_0, atom126.getTree());

                    }
                    break;

            }
            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "unaryExpr"

    public static class atom_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "atom"
    // WJ.g:178:1: atom : ( String | Number | Boolean | Identifier | functionCall | '(' expression ')' );
    public final WJParser.atom_return atom() throws RecognitionException {
        WJParser.atom_return retval = new WJParser.atom_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token String127=null;
        Token Number128=null;
        Token Boolean129=null;
        Token Identifier130=null;
        Token char_literal132=null;
        Token char_literal134=null;
        WJParser.functionCall_return functionCall131 = null;

        WJParser.expression_return expression133 = null;


        Object String127_tree=null;
        Object Number128_tree=null;
        Object Boolean129_tree=null;
        Object Identifier130_tree=null;
        Object char_literal132_tree=null;
        Object char_literal134_tree=null;

        try {
            // WJ.g:179:2: ( String | Number | Boolean | Identifier | functionCall | '(' expression ')' )
            int alt27=6;
            switch ( input.LA(1) ) {
            case String:
                {
                int LA27_1 = input.LA(2);

                if ( ((LA27_1>=Length && LA27_1<=CharAt)) ) {
                    alt27=5;
                }
                else if ( (LA27_1==51||LA27_1==54||LA27_1==56||(LA27_1>=59 && LA27_1<=60)||LA27_1==62||LA27_1==64||(LA27_1>=67 && LA27_1<=80)) ) {
                    alt27=1;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("", 27, 1, input);

                    throw nvae;
                }
                }
                break;
            case Number:
                {
                alt27=2;
                }
                break;
            case Boolean:
                {
                alt27=3;
                }
                break;
            case Identifier:
                {
                int LA27_4 = input.LA(2);

                if ( ((LA27_4>=Length && LA27_4<=CharAt)||LA27_4==53||LA27_4==57) ) {
                    alt27=5;
                }
                else if ( (LA27_4==51||LA27_4==54||LA27_4==56||(LA27_4>=59 && LA27_4<=60)||LA27_4==62||LA27_4==64||(LA27_4>=67 && LA27_4<=80)) ) {
                    alt27=4;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("", 27, 4, input);

                    throw nvae;
                }
                }
                break;
            case Write:
            case WriteLine:
            case ReadString:
            case ReadNumber:
            case Connect:
            case Take:
            case Drop:
                {
                alt27=5;
                }
                break;
            case 53:
                {
                alt27=6;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 27, 0, input);

                throw nvae;
            }

            switch (alt27) {
                case 1 :
                    // WJ.g:179:4: String
                    {
                    root_0 = (Object)adaptor.nil();

                    String127=(Token)match(input,String,FOLLOW_String_in_atom1129); 
                    String127_tree = (Object)adaptor.create(String127);
                    adaptor.addChild(root_0, String127_tree);


                    }
                    break;
                case 2 :
                    // WJ.g:180:4: Number
                    {
                    root_0 = (Object)adaptor.nil();

                    Number128=(Token)match(input,Number,FOLLOW_Number_in_atom1134); 
                    Number128_tree = (Object)adaptor.create(Number128);
                    adaptor.addChild(root_0, Number128_tree);


                    }
                    break;
                case 3 :
                    // WJ.g:181:4: Boolean
                    {
                    root_0 = (Object)adaptor.nil();

                    Boolean129=(Token)match(input,Boolean,FOLLOW_Boolean_in_atom1139); 
                    Boolean129_tree = (Object)adaptor.create(Boolean129);
                    adaptor.addChild(root_0, Boolean129_tree);


                    }
                    break;
                case 4 :
                    // WJ.g:182:4: Identifier
                    {
                    root_0 = (Object)adaptor.nil();

                    Identifier130=(Token)match(input,Identifier,FOLLOW_Identifier_in_atom1144); 
                    Identifier130_tree = (Object)adaptor.create(Identifier130);
                    adaptor.addChild(root_0, Identifier130_tree);


                    }
                    break;
                case 5 :
                    // WJ.g:183:4: functionCall
                    {
                    root_0 = (Object)adaptor.nil();

                    pushFollow(FOLLOW_functionCall_in_atom1149);
                    functionCall131=functionCall();

                    state._fsp--;

                    adaptor.addChild(root_0, functionCall131.getTree());

                    }
                    break;
                case 6 :
                    // WJ.g:184:4: '(' expression ')'
                    {
                    root_0 = (Object)adaptor.nil();

                    char_literal132=(Token)match(input,53,FOLLOW_53_in_atom1154); 
                    char_literal132_tree = (Object)adaptor.create(char_literal132);
                    adaptor.addChild(root_0, char_literal132_tree);

                    pushFollow(FOLLOW_expression_in_atom1156);
                    expression133=expression();

                    state._fsp--;

                    adaptor.addChild(root_0, expression133.getTree());
                    char_literal134=(Token)match(input,54,FOLLOW_54_in_atom1158); 
                    char_literal134_tree = (Object)adaptor.create(char_literal134);
                    adaptor.addChild(root_0, char_literal134_tree);


                    }
                    break;

            }
            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "atom"

    // Delegated rules


    protected DFA17 dfa17 = new DFA17(this);
    static final String DFA17_eotS =
        "\15\uffff";
    static final String DFA17_eofS =
        "\15\uffff";
    static final String DFA17_minS =
        "\1\30\5\uffff\1\41\2\uffff\1\41\3\uffff";
    static final String DFA17_maxS =
        "\1\45\5\uffff\1\71\2\uffff\1\42\3\uffff";
    static final String DFA17_acceptS =
        "\1\uffff\1\1\1\2\1\3\1\4\1\5\1\uffff\1\10\1\11\1\uffff\1\6\1\12"+
        "\1\7";
    static final String DFA17_specialS =
        "\15\uffff}>";
    static final String[] DFA17_transitionS = {
            "\1\6\3\uffff\1\1\1\2\1\3\1\4\1\5\2\uffff\1\7\1\10\1\11",
            "",
            "",
            "",
            "",
            "",
            "\1\12\1\14\22\uffff\1\13\3\uffff\1\13",
            "",
            "",
            "\1\12\1\14",
            "",
            "",
            ""
    };

    static final short[] DFA17_eot = DFA.unpackEncodedString(DFA17_eotS);
    static final short[] DFA17_eof = DFA.unpackEncodedString(DFA17_eofS);
    static final char[] DFA17_min = DFA.unpackEncodedStringToUnsignedChars(DFA17_minS);
    static final char[] DFA17_max = DFA.unpackEncodedStringToUnsignedChars(DFA17_maxS);
    static final short[] DFA17_accept = DFA.unpackEncodedString(DFA17_acceptS);
    static final short[] DFA17_special = DFA.unpackEncodedString(DFA17_specialS);
    static final short[][] DFA17_transition;

    static {
        int numStates = DFA17_transitionS.length;
        DFA17_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA17_transition[i] = DFA.unpackEncodedString(DFA17_transitionS[i]);
        }
    }

    class DFA17 extends DFA {

        public DFA17(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 17;
            this.eot = DFA17_eot;
            this.eof = DFA17_eof;
            this.min = DFA17_min;
            this.max = DFA17_max;
            this.accept = DFA17_accept;
            this.special = DFA17_special;
            this.transition = DFA17_transition;
        }
        public String getDescription() {
            return "90:1: functionCall : ( Write ( '()' | '(' ( expression )? ')' ) -> ^( FUNCTION_CALL Write ( expression )? ) | WriteLine ( '()' | '(' ( expression )? ')' ) -> ^( FUNCTION_CALL WriteLine ( expression )? ) | ReadString ( '()' | '(' ')' ) -> ^( FUNCTION_CALL ReadString ) | ReadNumber ( '()' | '(' ')' ) -> ^( FUNCTION_CALL ReadNumber ) | Connect '(' expression ( ',' expression )+ ')' -> ^( FUNCTION_CALL Connect ( expression )+ ) | stringExpr Length -> ^( FUNCTION_CALL Length stringExpr ) | stringExpr CharAt '[' expression ']' -> ^( FUNCTION_CALL CharAt stringExpr expression ) | Take expression 'characters' 'from' stringExpr -> ^( FUNCTION_CALL Take expression stringExpr ) | Drop expression 'characters' 'from' stringExpr -> ^( FUNCTION_CALL Drop expression stringExpr ) | Identifier ( '()' | '(' ( argumentList )? ')' ) -> ^( FUNCTION_CALL Identifier ( argumentList )? ) );";
        }
    }
 

    public static final BitSet FOLLOW_block_in_parse139 = new BitSet(new long[]{0x0000000000000000L});
    public static final BitSet FOLLOW_EOF_in_parse141 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_statement_in_block166 = new BitSet(new long[]{0x800000B9F3800002L});
    public static final BitSet FOLLOW_functionDeclaration_in_block170 = new BitSet(new long[]{0x800000B9F3800002L});
    public static final BitSet FOLLOW_Return_in_block175 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_expression_in_block177 = new BitSet(new long[]{0x0008000000000000L});
    public static final BitSet FOLLOW_51_in_block179 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_assignment_in_statement221 = new BitSet(new long[]{0x0008000000000000L});
    public static final BitSet FOLLOW_51_in_statement224 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_functionCall_in_statement234 = new BitSet(new long[]{0x0008000000000000L});
    public static final BitSet FOLLOW_51_in_statement236 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ifStatement_in_statement245 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_whileStatement_in_statement256 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Identifier_in_assignment275 = new BitSet(new long[]{0x0010000000000000L});
    public static final BitSet FOLLOW_52_in_assignment277 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_expression_in_assignment279 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_CreateFunction_in_functionDeclaration303 = new BitSet(new long[]{0x0000000001000000L});
    public static final BitSet FOLLOW_Identifier_in_functionDeclaration305 = new BitSet(new long[]{0x0080000004000000L});
    public static final BitSet FOLLOW_WithParameters_in_functionDeclaration308 = new BitSet(new long[]{0x0020000000000000L});
    public static final BitSet FOLLOW_53_in_functionDeclaration310 = new BitSet(new long[]{0x0040000001000000L});
    public static final BitSet FOLLOW_parameterList_in_functionDeclaration312 = new BitSet(new long[]{0x0040000001000000L});
    public static final BitSet FOLLOW_54_in_functionDeclaration315 = new BitSet(new long[]{0x0080000000000000L});
    public static final BitSet FOLLOW_55_in_functionDeclaration319 = new BitSet(new long[]{0x800000B9F3800000L});
    public static final BitSet FOLLOW_block_in_functionDeclaration321 = new BitSet(new long[]{0x0000000008000000L});
    public static final BitSet FOLLOW_EndFunction_in_functionDeclaration323 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_expression_in_argumentList335 = new BitSet(new long[]{0x0100000000000002L});
    public static final BitSet FOLLOW_56_in_argumentList338 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_expression_in_argumentList340 = new BitSet(new long[]{0x0100000000000002L});
    public static final BitSet FOLLOW_Identifier_in_parameterList373 = new BitSet(new long[]{0x0100000000000002L});
    public static final BitSet FOLLOW_56_in_parameterList377 = new BitSet(new long[]{0x0000000001000000L});
    public static final BitSet FOLLOW_Identifier_in_parameterList381 = new BitSet(new long[]{0x0100000000000002L});
    public static final BitSet FOLLOW_Write_in_functionCall408 = new BitSet(new long[]{0x0220000000000000L});
    public static final BitSet FOLLOW_57_in_functionCall412 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_53_in_functionCall416 = new BitSet(new long[]{0x00600C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_expression_in_functionCall418 = new BitSet(new long[]{0x0040000000000000L});
    public static final BitSet FOLLOW_54_in_functionCall421 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_WriteLine_in_functionCall438 = new BitSet(new long[]{0x0220000000000000L});
    public static final BitSet FOLLOW_57_in_functionCall441 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_53_in_functionCall445 = new BitSet(new long[]{0x00600C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_expression_in_functionCall447 = new BitSet(new long[]{0x0040000000000000L});
    public static final BitSet FOLLOW_54_in_functionCall450 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ReadString_in_functionCall467 = new BitSet(new long[]{0x0220000000000000L});
    public static final BitSet FOLLOW_57_in_functionCall470 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_53_in_functionCall474 = new BitSet(new long[]{0x0040000000000000L});
    public static final BitSet FOLLOW_54_in_functionCall476 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ReadNumber_in_functionCall489 = new BitSet(new long[]{0x0220000000000000L});
    public static final BitSet FOLLOW_57_in_functionCall492 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_53_in_functionCall496 = new BitSet(new long[]{0x0040000000000000L});
    public static final BitSet FOLLOW_54_in_functionCall498 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Connect_in_functionCall511 = new BitSet(new long[]{0x0020000000000000L});
    public static final BitSet FOLLOW_53_in_functionCall513 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_expression_in_functionCall515 = new BitSet(new long[]{0x0100000000000000L});
    public static final BitSet FOLLOW_56_in_functionCall518 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_expression_in_functionCall520 = new BitSet(new long[]{0x0140000000000000L});
    public static final BitSet FOLLOW_54_in_functionCall524 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_stringExpr_in_functionCall540 = new BitSet(new long[]{0x0000000200000000L});
    public static final BitSet FOLLOW_Length_in_functionCall542 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_stringExpr_in_functionCall557 = new BitSet(new long[]{0x0000000400000000L});
    public static final BitSet FOLLOW_CharAt_in_functionCall559 = new BitSet(new long[]{0x0400000000000000L});
    public static final BitSet FOLLOW_58_in_functionCall561 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_expression_in_functionCall563 = new BitSet(new long[]{0x0800000000000000L});
    public static final BitSet FOLLOW_59_in_functionCall565 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Take_in_functionCall582 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_expression_in_functionCall584 = new BitSet(new long[]{0x1000000000000000L});
    public static final BitSet FOLLOW_60_in_functionCall586 = new BitSet(new long[]{0x2000000000000000L});
    public static final BitSet FOLLOW_61_in_functionCall588 = new BitSet(new long[]{0x0000002001000000L});
    public static final BitSet FOLLOW_stringExpr_in_functionCall590 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Drop_in_functionCall607 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_expression_in_functionCall609 = new BitSet(new long[]{0x1000000000000000L});
    public static final BitSet FOLLOW_60_in_functionCall611 = new BitSet(new long[]{0x2000000000000000L});
    public static final BitSet FOLLOW_61_in_functionCall613 = new BitSet(new long[]{0x0000002001000000L});
    public static final BitSet FOLLOW_stringExpr_in_functionCall615 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Identifier_in_functionCall632 = new BitSet(new long[]{0x0220000000000000L});
    public static final BitSet FOLLOW_57_in_functionCall635 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_53_in_functionCall639 = new BitSet(new long[]{0x00600C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_argumentList_in_functionCall640 = new BitSet(new long[]{0x0040000000000000L});
    public static final BitSet FOLLOW_54_in_functionCall642 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_set_in_stringExpr0 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ifStatementPart_in_ifStatement684 = new BitSet(new long[]{0x0000034000000000L});
    public static final BitSet FOLLOW_elseIfStatementPart_in_ifStatement686 = new BitSet(new long[]{0x0000034000000000L});
    public static final BitSet FOLLOW_elseStatementPart_in_ifStatement689 = new BitSet(new long[]{0x0000004000000000L});
    public static final BitSet FOLLOW_EndIf_in_ifStatement692 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_If_in_ifStatementPart719 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_expression_in_ifStatementPart721 = new BitSet(new long[]{0x4000000000000000L});
    public static final BitSet FOLLOW_62_in_ifStatementPart723 = new BitSet(new long[]{0x0080000000000000L});
    public static final BitSet FOLLOW_55_in_ifStatementPart725 = new BitSet(new long[]{0x800000B9F3800000L});
    public static final BitSet FOLLOW_block_in_ifStatementPart727 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ElseIf_in_elseIfStatementPart749 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_expression_in_elseIfStatementPart751 = new BitSet(new long[]{0x4000000000000000L});
    public static final BitSet FOLLOW_62_in_elseIfStatementPart753 = new BitSet(new long[]{0x0080000000000000L});
    public static final BitSet FOLLOW_55_in_elseIfStatementPart755 = new BitSet(new long[]{0x800000B9F3800000L});
    public static final BitSet FOLLOW_block_in_elseIfStatementPart757 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Else_in_elseStatementPart779 = new BitSet(new long[]{0x0080000000000000L});
    public static final BitSet FOLLOW_55_in_elseStatementPart781 = new BitSet(new long[]{0x800000B9F3800000L});
    public static final BitSet FOLLOW_block_in_elseStatementPart783 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_63_in_whileStatement803 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_expression_in_whileStatement806 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_64_in_whileStatement808 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000002L});
    public static final BitSet FOLLOW_65_in_whileStatement810 = new BitSet(new long[]{0x0080000000000000L});
    public static final BitSet FOLLOW_55_in_whileStatement812 = new BitSet(new long[]{0x800000B9F3800000L});
    public static final BitSet FOLLOW_block_in_whileStatement814 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000004L});
    public static final BitSet FOLLOW_66_in_whileStatement816 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_andExpr_in_expression828 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000008L});
    public static final BitSet FOLLOW_67_in_expression831 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_andExpr_in_expression833 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000008L});
    public static final BitSet FOLLOW_relExpr_in_andExpr855 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000010L});
    public static final BitSet FOLLOW_68_in_andExpr858 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_relExpr_in_andExpr860 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000010L});
    public static final BitSet FOLLOW_arimExpr_in_relExpr883 = new BitSet(new long[]{0x0000000000000002L,0x00000000000007E0L});
    public static final BitSet FOLLOW_relOp_in_relExpr886 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_arimExpr_in_relExpr888 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_set_in_relOp0 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_mulExpr_in_arimExpr960 = new BitSet(new long[]{0x0000000000000002L,0x0000000000001800L});
    public static final BitSet FOLLOW_addSub_in_arimExpr963 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_mulExpr_in_arimExpr965 = new BitSet(new long[]{0x0000000000000002L,0x0000000000001800L});
    public static final BitSet FOLLOW_set_in_addSub0 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_powExpr_in_mulExpr1014 = new BitSet(new long[]{0x0000000000000002L,0x000000000000E000L});
    public static final BitSet FOLLOW_mulDivMod_in_mulExpr1017 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_powExpr_in_mulExpr1019 = new BitSet(new long[]{0x0000000000000002L,0x000000000000E000L});
    public static final BitSet FOLLOW_set_in_mulDivMod0 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_unaryExpr_in_powExpr1072 = new BitSet(new long[]{0x0000000000000002L,0x0000000000010000L});
    public static final BitSet FOLLOW_80_in_powExpr1075 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_unaryExpr_in_powExpr1077 = new BitSet(new long[]{0x0000000000000002L,0x0000000000010000L});
    public static final BitSet FOLLOW_76_in_unaryExpr1101 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_atom_in_unaryExpr1104 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_81_in_unaryExpr1109 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_atom_in_unaryExpr1112 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_atom_in_unaryExpr1117 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_String_in_atom1129 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Number_in_atom1134 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Boolean_in_atom1139 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Identifier_in_atom1144 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_functionCall_in_atom1149 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_53_in_atom1154 = new BitSet(new long[]{0x00200C39F1000000L,0x0000000000021000L});
    public static final BitSet FOLLOW_expression_in_atom1156 = new BitSet(new long[]{0x0040000000000000L});
    public static final BitSet FOLLOW_54_in_atom1158 = new BitSet(new long[]{0x0000000000000002L});

}